Coder Social home page Coder Social logo

scriptaria / quick-express Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 2.0 1.41 MB

A ready to use rest API structure made with Express.js and Typescript.

Home Page: https://scriptaria.com/projetos/quick-express

License: MIT License

TypeScript 97.95% JavaScript 0.67% Dockerfile 0.67% Shell 0.71%
expressjs nodejs api rest-api typescript jwt jest apidoc rest

quick-express's Introduction

CodeFactor Github Actions - Test CI

Quick Express

A ready to use rest API structure made with Express.js and Typescript.

Quick Express counts with:

  • ORM (TypeORM)
  • Tests (Jest and Super Test)
  • API Documentation (apidoc)
  • JWT Authentication
  • A request parameters (request.body, request.query, request.params) validation system (that uses validate.js)
  • A great and organized project structure.

Getting started

Configure and understand your project

Environment settings

You will need a .env file. In this file, you put all your sensitive and environment info.

Running the command npm run generate env sqlite, a .env file will be generated using the requested template (sqlite, mysql or postgres).

Note¹: sqlite, mysql and postgres are just the supported templates by the CLI for now, but you can use any database that is supported by TypeORM

Note²: if you prefer, you can just make a copy of .env.example and name it as .env

Is recommended to not commit the .env file.

The src directory is where your source code stays.

  • Your modules (routes and endpoints) in src/modules/
  • Your middleware in src/middleware/
  • Your db models in src/models/

The project already comes with a module called users. It provides secure authentication for your project using JWT.

POST /users - Create a new user
POST /users/login - Login with email and password
POST /users/refresh - Get new access and refresh tokens

And the project also comes with a module called 'tasks', that shows you the appropriate way to make a good REST API. These endpoints only work with authenticated users.

GET /tasks - Retrieves all logged user tasks
GET /tasks/1 - Retrieves a specific task by id
POST /tasks - Creates a new task
PATCH /tasks/1 - Updates task #1
DELETE /tasks/1 - Deletes task #1

You can see all the default endpoints that comes with Quick Express in the requests.http file, and you can use REST Client to test it all in VSCode.

CLI Tool

The project also comes with a simple CLI tool to generate components such as Models and Modules, take a try:

npm run generate module nameOfMyModule
npm run generate model nameOfMyModel
npm run generate middleware nameOfMyMiddleware
npm run generate env sqlite
npm run generate env mysql
npm run generate env postgres

Documentation

Quick Express comes with apidoc. Run npm run doc to generate de doc on /doc folder.

Consider consulting the apidoc documentation to learn more.

Install your node dependencies

npm install

Running

npm start

quick-express's People

Contributors

dependabot[bot] avatar josecfreittas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.