Skip to content

ahmetfturgut/nodejs-server

Repository files navigation

Project src structure directories.

src/
├─ config/
│  ├─ config.js
├─ controller.js
│  ├─ controller.index.js
│  ├─ userController.js
├─ loader/
│  ├─ express.js
│  ├─ mongoose.js
│  ├─ server.js
├─ middlewares/
│  ├─ middlewares.index.js
│  ├─ validator.js
├─ routes/
│  ├─ routes.index.js
│  ├─ routes.js
│  ├─ userRoute.js
├─ utils/
│  ├─ requestUtil.js
│  ├─ utils.index.js
test/
├─ example.test.js
├─ userController.test.js
└─

Features

  • ES9: latest ECMAScript features
  • NoSQL database: MongoDB object data modeling using Mongoose
  • Authentication and authorization: using jsonwebtoken
  • Validation: request data validation using Joi
  • Logging: //TODO: winston
  • Testing: unit and integration tests using Mocha Chai
  • Error handling: centralized error handling mechanism
  • API documentation: //TODO: swagger
  • Dependency management: with Npm
  • Environment variables: using dotenv
  • Security: set security HTTP headers using helmet
  • Santizing: sanitize request data against xss and query injection
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Compression: //TODO: gzip compression with compression
  • CI: continuous integration with Travis CI
  • Docker support
  • Code coverage: using coveralls
  • Code quality: with Codacy
  • Git hooks: with husky
  • Linting: with ESLint and Prettier
  • Editor config: consistent editor configuration using EditorConfig

Getting Started

Installation

Clone the repo:

git clone https://github.com/ahmetfturgut/nodejs-server.git
cd nodejs-restapi

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Commands

Running locally:

npm run start

Lint

# lint code with ESLint
npm run lint

Test

# run all tests with Mocha
npm run test

# run test coverage
npm run test:coverage

Contributing

Contributions are more than welcome! Please check out the contributing guide.

Inspirations

License

MIT

nodejs-server