Skip to content

Simple RESTful API using Express, Mongo as backend and Isomorphic React as a front-end layer with websockets for live notifications and redux, sagas for state management and side effects. A GraphQL implementation is also available.

License

Notifications You must be signed in to change notification settings

FiF0o/books-API

Repository files navigation

Books-API



This is a simple server side App offering a web API as well as a front based a GraphQL & MongoDB implementations.

  • GraphQL implementation is available on the graphql branch as well as master.
  • MongoDB implementation available on mongo branch.

The front-end uses ReactJs and Material design css with Material Components Web library:

  • Redux for state management, Sagas for side-effects & Websocket for live updates on the mongo branch.
  • PrismaDB, Apollo is used on the graphql branch to interface with graphQL.

1. Pre-requisites


You must add your DATABASE endpoints for your environments in the config directory.

./
 __config/
  package.json
 .env
 ...



The API is served by default on PORT:3000.
The Web app is served by default on PORT:3001.


1.1 Dependencies

You must have MongoDB installed on your machine or PrismaDB.

1.2 Environment

Env variables are loaded with dotenv.
Before running the project don't forget to add the following variables in your .env file.

// MongoDB variables for differents environments...
DEV_DB
PROD_DB


// API endpoints, ports... for MongoDB, GraphQL
API_PORT=

// App env variables...
APP_PORT=

// Prisma DB variables:  App & DB layers, Authentication/Encryption Token
PRISMA_DB_ENDPOINT=
PRISMA_DB_SECRET=
PRISMA_CLUSTER=
PRISMA_BEARER_TOKEN=

(Refer to the env file for help)

1.3 MongoDB implementation

mongo shell to test & debug.

  • Runs on PORT:3000
  • Routes & endpoints:
    • /api/books/
    • /api/books/:id
    • /api/genres/
    • /api/genres/:id
  • Mongoose ODM (Schema, Controllers):
      ./
      __api/
      ____resources/
      ______ <resource>/
      ________ index.js
      ________ <resource>.controller.js
      ________ <resource>.model.js
      ________ <resource>.router.js
      ...
      ______ router.js
      ______ index.js
    


1.4 GraphQL inplementation

GraphQL, Prisma ORM.

  • Application layer (GraphQL):
    ./
    __/api/
    ____schema.graphql
    ____index.js
    
  • Database layer (Prisma & bindings):
    ./
    __database/
    ____datamodel.graphql
    ____prisma.yml
    

Additional documentation:




2. Commands

  • Running the project: npm run start
  • Developing: npm run dev
  • Running the web API: npm run api
  • Running the web server: npm run server
  • Bundling the artefacts: npm run build
  • (optional) mongoDB cluster: npm run db



3. Next steps


  • Testing.
  • CI/CD.
  • Styling on the graphql branch.

About

Simple RESTful API using Express, Mongo as backend and Isomorphic React as a front-end layer with websockets for live notifications and redux, sagas for state management and side effects. A GraphQL implementation is also available.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published