Coder Social home page Coder Social logo

express-typescript-skeleton's Introduction

Technologies

This is a Express JS project with Typescript.

  • Database : MySQL
  • Authentication : JWT
  • ORM : TypeORM

Run the App

To run the app, first install all dependencies by doing :

yarn install

and to start the Express JS Server

yarn run start

Running in production

To actually run the project in production, you must first install the Task manager "PM2".

yarn run start:production

This command will create a process "api". The process node can be change on package.json file.

Project structure ๐Ÿ—

The API codebase is fairly simple and should be easy enough to understand.


File or folder Description
src/index.ts The entry file. This is where we setup middleware, attach routes, initialize database and express.
src/routes.ts This is where we define all routes, both public and private.
src/constants Constants are values that never change and are used in multiple places across the codebase.
src/controllers Controllers listen to client's requests and work with entities and the database to fetch, add, update, or delete data.
src/database Database related code and seeds go here.
src/entities This is where we put TypeORM entities, you could think of them as models. We define columns, relations, validations for each database entity.
src/errors This is where we define custom errors. The catchErrors function helps us avoid repetitive try/catch blocks within controllers.
src/middleware Middleware functions can modify request and response objects, end the request-response cycle, etc. For example authenticateUser method verifies the authorization token and attaches currentUser to the request object.
src/serializers Serializers transform the data fetched from the database before it's sent to the client.
src/utils Utility(helper) functions that are used in multiple places across the codebase. For example utils/typeorm.ts functions help us validate data and avoid writing repetitive code.

express-typescript-skeleton's People

Contributors

fabriceyopa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.