Code Monkey home page Code Monkey logo

json-api-express's Introduction

json-api-express

Demo app built with Express, Mongoose to demonstrate a fully working JSON API implementation.

It is a work in progress. Some features need to be implement to have a complete working example API. Some missing features : Errors, Payload validation, etc...

Feel free to contribute to build a fully working JSON API example.

Installation

  1. git clone https://github.com/danivek/json-api-express.git
  2. npm install
  3. npm start
  4. Browse http://localhost:8080/docs

Usage

This is a sample app modeling a blog with articles, author, comments, tags, etc...

Try some endpoints :

Or explore api endpoints with swagger-ui at : http://localhost:8080/docs

Features

Prerequisites

  • MongoDB - Download and Install MongoDB - you'll need mongoDB to be installed and have the mongod process running.
  • Node.js 4+ or above

json-api-express's People

Contributors

danivek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

json-api-express's Issues

Swagger

Dear @danivek ,

thank you very much for this demo project showcasing the use of your json-api-serializer and express.js. I stumbled upon a question, you may be able to answer:

You are manually generating the swagger.json file in the docs folder, right? This means, you are currently manually defining the input and output structures of the JsonAPI objects that are sent / returned by the API, right?

Would it be possible to auto-generate these information? E.g., the structure of the paginated /articles route? Because currently, i see the following issue:

  1. You must define your own "internal model" of the Article (e.g,. the structure of the model how it is stored in the database).
  2. Then you are defining the serializer where you are (partially) re-writing information (e.g., how are fields mapped, which fields are the attributes to be serialized, and so on)
  3. Then, again, you would need to create some kind of "output model" (plain class that you actually NEVER use in your application) to tell Swagger how the data actually look like

I mean, 1 & 2 are steps you actually need to do - there is not much to talk about this.. But 3 seems kind of redundant.. Do you get what i mean?!

I am totally aware that Json:API and Swagger - kind of - are orthogonal with their goals.. e.g., Json:API aims at providing a clear structure how the documents must look like, how routes are formed, which query params are valid and so on.. Swagger, on the other, aims at providing some kind of explorative documentation - that allows for automatically generating code snippets to interact with the API.

So the next question could be: Is it possible to use the best of both approaches? Like, get the "structure" of the data that is serialized by the Serializer and then - somehow - use this information within Swagger? Do you have any ideas / suggestions on this?

All the best

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.