@danny270793/tsframework
v1.1.0
Published
A minimalist typescript web framework
Downloads
2
Readme
TSFramework
TSFramework is typescript microframework for an educational porposes
Instalation
Install package from public registry
npm install @danny270793/tsframework
Example
Import the library
import { TSFramework, Router, Request } from '@danny270793/tsframework'
Create how many routers you need
const apiRouter: Router = new Router()
Register a callback for the path /users/:user_id/location/:location_id
just for get
requests
Notice that the callback must return something, the framework serializes that return to json automatically before sent it back to the client
apiRouter.get(
'/users/:user_id/location/:location_id',
async (request: Request<any>): Promise<Request<any>> => {
return request
}
)
Create a TSFramework
instance and set
it the router with a prefix, then run the web server in an specific port
const port: number = 8000
const app: TSFramework = new TSFramework()
app.set('/api', apiRouter)
app.run(port)
Test the library
curl -X GET http://127.0.0.1:8000//users/25/location/35?key1=value1&key2=value2
Follow me
LICENSE
Licensed under the MIT License
Version
TSFramework version 1.0.0
Last update 09/03/2023