Welcome to TyRAS-oriented Node HTTP server app!
This app is using runtypes
as data validation framework.
The contents of this folder were created using ty-ras/start
npx starter template.
As a very first task, it is good idea to pick your favourite testing framework, and write some tests for the code.
As a good second task, one can run development server.
To do that, simply install dependencies (if not already done during project creation stage), and execute dev
script from package.json
:
yarn install && yarn run dev
After running the command above, the text Started server at <host>:<port>
will signal that HTTP server is now listening at given port.
The src
folder contains all the code.
That folder is further structured in the following way:
api
folder contains all code related to HTTP server.protocol
subfolder contains type definitions related to exposed HTTP endpoints and the data flowing between them. This is the core which utilizes some TyRAS interfaces, but mostly it is just defining the endpoint shape using TypeScript types, and data contents usingruntypes
validators.endpoints
subfolder contains the code which constructs the endpoints defined by protocol component, using functions and constants provided by TyRAS framework.index.ts
ties all of the above together to exposeapiEndpoints
constant which contains all endpoints for TyRAS HTTP server to run.
auth
folder containsindex.ts
, which can be modified to implement authentication code.config.ts
file contains deserialized and validated configuration for the program. The deserialization usesMY_BACKEND_CONFIG
environment variable, which is good idea to change to something else. It currently only has HTTP server host and port, and CORS settings, but it can easily be expanded to encompass things like DB connection configs, resource pool eviction settings, and so on. The development configuration matching this validator is inconfig-dev.json
file.index.ts
file is an entrypoint to the program. The program will start the TyRAS HTTP server using configuration inconfig.ts
file.