GithubHelp home page GithubHelp logo

ardalanamini / express-api-template Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 1.09 MB

This is a starter Express.js API Template, helping to get past the routine of starting a new project from scratch again and again!

License: MIT License

TypeScript 76.95% Shell 1.61% JavaScript 20.49% Dockerfile 0.95%
node nodejs node-js express expressjs express-js typescript eslint jest swagger codecov docker sentry docker-compose mongodb mongoose typedoc

express-api-template's Introduction

Express.js API Template

Test CodeCov

This is a starter Express.js1 API Template, helping to get past the routine of starting a new project from scratch again and again!

This template is still in WIP phase!

Table of Contents

Prerequisites

  • Node.js3 (v16.13.2 or higher)
  • MongoDB4 (v5)

Usage

First install the dependencies:

npm i

Build

Build the project. (Using TypeScript5)

npm run build

Watch for changes and rebuild automatically.

npm run build:watch

Test

Test the project. (Using Jest6)

npm test

Test with code coverage report.

npm run test:coverage

Test in ci.

npm run test:ci

Code Style

Check for code style issues in the project. (Using ESLint7)

npm run lint

Fix code style issues in the project.

npm run lint:fix

Documents

API Documents

Generate the API documents to be served statically. (Using Swagger8)

npm run docs:swagger

Generate & serve the API documents. (The documents' server address will be printed in the terminal)

npm run docs:api

Code Documents

Generate the Code documents to be served statically. (Using TypeDoc9)

npm run docs:code

After running this command, open docs/code/index.html in your preferred browser.

Config

First create the .env file:

cp .env.example .env

Common Config

Name Type Default Description
NODE_ENV production,development,test development Node.js3 environment (test will be provided by the testing framework automatically)
RELEASE_ENV production,staging staging Release environment

Server Config

Name Type Default Description
SERVER_HOSTNAME string localhost Express.js1 server hostname
SERVER_PORT integer 3000 Express.js1 server port

Database Config

Name Type Default Description
DATABASE_URI string - MongoDB4 connection string uri

Sentry Config

Name Type Default Description
SENTRY_DSN string - Sentry10 project DSN value

Start

Start the API.

npm start

Watch for changes and restart automatically.

npm run start:watch

Docker

Start the services:

docker-compose up -d --build --remove-orphans

Stop the services:

docker-compose down

Directory Layout

.
├── __tests__        # Test files
│   ├── controllers  # Express.js controller tests
│   └── jest         # Test utilities
├── docs             # Static documents
│   ├── api          # API documents
│   └── code         # Code documents
├── scripts          # Project scripts
└── src              # Source files
    ├── config       # Configuration values
    ├── constants    # Constants
    ├── controllers  # Express.js controllers
    ├── lib          # Libraries
    └── models       # Database models

Versioning

We use SemVer11 for versioning. For the versions & changelogs available, see the releases on this repository.

Footnotes

  1. Express.js 2 3

  2. Docker

  3. Node.js 2

  4. MongoDB 2

  5. TypeScript

  6. Jest

  7. ESLint

  8. Swagger

  9. TypeDoc

  10. Sentry

  11. SemVer

express-api-template's People

Contributors

ardalanamini avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

roinizri

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.