# Introduction
express-api-bootstrap
is a controller-based framework that supports springMVC flavor decorators, @RestController
, @GetMapping
. A dead simple plugin system that covers core lifecycles while from launching to application running.
express-api-bootstrap
is a express.js based node framework. It should be used in small/medium-sized projects.
# Features
- Convention over configuration
- Type system coding experience based on typescript
- Damn easy plugin system
- Spring MVC like API interface
- Debug is easy via vscode
- Write/Execute unit-test is easy
# Architecture
TBD
# Getting Started
# Environmental preparation
First you should have node.js installed, and make sure the version >= 10
.
# Boilerplate
Create an empty directory for your application:
mkdir your-app && cd your-app
Init npm env:
npm init -y
Add required dependencies:
yarn add express-api-bootstrap
Init express-api-bootstrap
required env:
npx boot init
Add express-api-bootstrap
provided scripts to your package.json
:
{
"scripts": {
"start": "boot dev",
"build": "boot build",
"serve": "boot serve",
"test": "boot test"
}
}
Create your first controller at src/controllers/helloController.ts
with following code:
import { HttpRequest, RestController, GetMapping } from 'express-api-bootstrap'
@RestController()
class HelloControler {
@GetMapping('/hello')
sayHello(req: HttpRequest) {
return {
say: `Hi, ${req.query.name}`
}
}
}
export default HelloControler
Run yarn start
to, and you will see the first API at http://localhost:8080/apis/hello