Go to file Use this template
Sambo Chea 5120752ecb
All checks were successful
continuous-integration/drone/push Build is passing
Updated readme and quide
2021-09-14 09:50:25 +07:00
.husky Updated husky and install for prettier 2021-09-13 20:28:43 +07:00
packages Task: Updated lerna.json and add yarn workspaces and ts-common package and fixed the tsconfig 2021-09-13 20:19:28 +07:00
src Task: Fixed controller and application for routes and allow middleware for json and form urclosed 2021-09-14 09:44:25 +07:00
.dockerignore Task: Add Dockerfile and support DroneCI 2021-09-13 17:53:12 +07:00
.drone.yml Updated and build for ts common 2021-09-13 20:49:05 +07:00
.env Add server port in env 2021-09-13 20:50:53 +07:00
.eslintrc.js Task: Add express and nodejs application with TypeScript , Prettier and Husky 2021-09-13 17:49:01 +07:00
.gitignore Updated package and gitignore 2021-09-13 20:53:05 +07:00
.gitmodules Task: Updated lerna.json and add yarn workspaces and ts-common package and fixed the tsconfig 2021-09-13 20:19:28 +07:00
.prettierrc.json Task: Add express and nodejs application with TypeScript , Prettier and Husky 2021-09-13 17:49:01 +07:00
Dockerfile Task: Add Dockerfile and support DroneCI 2021-09-13 17:53:12 +07:00
lerna.json Task: Updated lerna.json and add yarn workspaces and ts-common package and fixed the tsconfig 2021-09-13 20:19:28 +07:00
LICENSE Initial commit 2021-09-13 17:04:49 +07:00
package.json Task: Add reflection metadata for decorators and add basic implements for controller and express application and constants and app 2021-09-14 09:06:03 +07:00
README.md Updated readme and quide 2021-09-14 09:50:25 +07:00
tsconfig.json Task: Add reflection metadata for decorators and add basic implements for controller and express application and constants and app 2021-09-14 09:06:03 +07:00

Express Nodejs App

  • Nodejs
  • Express
  • TypeScript
  • Prettier
  • ESLint
  • Docker
  • DroneCI
  • Lerna Support
  • Support decorators

Quickstart

  • Start
yarn start
  • Navigate
curl http://localhost:3000/info
  • Response
{
    "startedAt": "2021-09-13T13:21:04.184Z",
    "message": "Instance id: presenter#143470",
    "status": "OK"
}

Quick Register Controller

  • Add new controller src/controller/home.controller.ts
import { Request, Response } from "express"
import Controller from "../decorators/controller.decorator"
import { Get, Post } from "../decorators/handlers.decorator"

const data: any[] = []

@Controller("/home")
export default class HomeController {
    constructor() {}

    @Get()
    public get(req: Request, res: Response) {
        res.json(data)
    }

    @Post()
    public create(req: Request, res: Response) {
        const body = req.body
        if (body == null) {
            return res.status(400).json({
                status: 400,
                message: "Data is required",
            })
        }

        data.push(body)
        res.json({
            message: "Data created successfully",
            body: body,
        })
    }
}
  • Register controller into index.ts (src/controllers/index.ts)
import IndexController from "./index.controller"
import PersonController from "./person.controller"
import HomeController from "./home.controller"

export const controllers = [IndexController, PersonController, HomeController]

Contributors