GithubHelp home page GithubHelp logo

wasdev2022 / node-express-ts-rest-api-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mkocik/node-express-ts-rest-api-boilerplate

0.0 0.0 0.0 83 KB

RESTful API boilerplate written in typescript, with the usage of express & mongodb

License: MIT License

Shell 0.40% TypeScript 97.81% Dockerfile 1.79%

node-express-ts-rest-api-boilerplate's Introduction

Scallable & Configurable API in node.js

  1. About
  2. Installation
  3. Usage
  4. Testing
  5. More
  6. Contributing
  7. License

About

The idea behind this project lies in simplicity. It is the template for a generic API with the implementation of user registration and authorization. It's just a sample of how to write a service, feel free to use this project whatever way you need.

The project uses some DDD practices, like Value Objects and Application Services.

The code is written in TypeScript. The API bases on the express library, with the service written in node.js. It uses MongoDB to store data and mocha & chai for testing purposes.

There is an error handling middleware implemented, so you don't have to worry about returning errors from the API. Just throw one and see the result!

Authentication is made with the use of jsonwebtoken library.

Installation

Use the package manager yarn to install dependencies.

yarn

Usage

You can run it either using the docker-compose up command:

docker-compose up

And open the url: http://localhost:8080/api/v1

Or you can open the user-service directory, rename .env.example file to .env and run one of the following commands:

yarn start
yarn dev
yarn debug
yarn prod

The advantage of the docker-compose is that it sets up the MongoDB database so you don't have to worry about it. And the more services you have, the harder it will be to run them 'by hand'.

To see the API documentation please open http://localhost:8080/api/v1/docs/

Testing

If you run the API using docker-compose up command all the tests are being executed.

But if you need to just run the tests, you can either use docker command:

docker-compose up --build --abort-on-container-exit

Or go directly to the service you want to test and run

yarn test

Single service structure

/src
.../api
.../application
.../common
.../db
.../events
.../exceptions
.../middlewares
.../models
/tests
...

More

If you want to know more about the structure and usage of this template, please feel free to visit https://medium.com/@mkocik/41c65f84d9c1 and check the article out!

Contributing

If you like the project enough to collaborate and you see some improvements to be made, please create a Pull Request.

License

MIT

node-express-ts-rest-api-boilerplate's People

Contributors

mkevolution avatar mkocik avatar

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.