akane10 / express-mongodb

boilerplate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EXPRESS MONGODB BOILERPLATE

This boilerplate is integrated with eslint airbnb-base and prettier and using jest for testing library. there's also some basic functional programming stuff (in helpers) like curry, pipe, compose, composePromise, pipePromise, you might need ramda library for beyond. This is not MVC approach, in fact, is referenced to nodebestpractices

File Structure

|-- api
    |-- components
        |-- articles
            |-- controller
                |-- create.js
            |-- ArticleModel.js
            |-- index.js // article routes
    |-- helpers
        |-- tests // unit test for helpers
            |-- index.test.js
        |-- fp.js
        |-- index.js
    |-- polices // middleware
        |-- verifyToken.js
    |-- index.js // all routes
|-- config
    |-- config.js
    |-- db.js
|-- tests // integration or routes tests
    |-- articles
        |-- create.test.js
    |-- data.js
|-- .env
|-- .eslintignore
|-- .eslintrc.json
|-- .gitignore
|-- .prettierrc
|-- app.js
|-- package.json
|-- server.js

Up and Running

  • create .env file
  • run yarn or npm install (delete yarn.lock first)
  • add this to .env file
    NODE_ENV=development
    URI=your_mongodb_uri
    SECRETKEY=SECRETKEY
    
  • and you're ready to go, run some commands
    yarn test // run jest test
    yarn dev // run nodemon along with dotenv
    yarn start // run node server
    

Depedencies

  • main
    • body-parser
    • cors
    • express
    • morgan
    • mongoose
  • dev
    • dotenv
    • eslint
    • eslint-config-airbnb-base
    • eslint-config-prettier
    • eslint-plugin-import
    • eslint-plugin-prettier
    • jest
    • prettier
    • supertest

About

boilerplate


Languages

Language:JavaScript 100.0%