0.1.3 • Published 4 years ago

@qubee/core v0.1.3

Weekly downloads
75
License
MIT
Repository
github
Last release
4 years ago

Qubee

What is Qubee ?

Qubee is a minimalist Typescript web framework based on ExpressJS. It uses decorators to improve the development experience.

How to use it ?

First, you need to install the package with npm.

npm i @qubee/core

Basic use:

// index.ts

// 1) Import the Server Class
import { Server } from '@qubee/core';

// 2) Import your middlewares / controllers
import middlewares from './middlewares'; // Array of middlewares
import controllers from './controllers'; // Array of controllers

// 3) Define the port
const PORT = 3000;

// 4) Create the server
const server = new Server(PORT);

// 5) Configure and start the server
server
	.configureMiddlewares(middlewares)
	.configureControllers(controllers)
	.start();

Basic Controller

// controllers/DefaultController.ts

import { Controller, Get } from '@qubee/core'
import { Request, Response, NextFunction } from 'express'

@Controller("/api")
export class DefaultController {
	
	@Get("/")
	public hello(req: Request, res: Response, Next: NextFunction){
		return res.status(200).send('Hello world !')
	}
}

To add it to the controllers:

// controllers/index.ts

import { DefaultController } from './DefaultController';

export default [
	DefaultController
]

Middlewares

Same thing for the middlewares:

// middlewares/index.ts

import helmet from 'helmet';

export default [
	helmet()
]