A minimalistic framework for typescript based applications, with async/await and decorators support.
This repository contains the v1 track for the TS Framework, which is now deprecated.
For an updated version checkout the v2 tree on nxtep-io/ts-framework fork.
Installing in your repository
# Install using Yarn
yarn add git+https://github.com/devnup/ts-framework.git#GIT_REV_HASH
# Install using NPM
npm install --save git+https://github.com/devnup/ts-framework.git#GIT_REV_HASH
Configure a new Server instance and start listening on desired port.
import Server, { Logger, BaseRequest, BaseResponse } from 'ts-framework';
// Define a sample hello world route
const SampleRoutes {
'/': async (req: BaseRequest, res: BaseResponse) => {
res.success({ message: 'Hello world!' });
}
}
// Define the server configuration
const server = new Server({
port: process.env.PORT as any || 3000,
routes: {
get: SampleRoutes,
},
});
// Startup the simple server
server.listen()
.then(() => Logger.info(`Server listening on port: ${server.config.port}`))
.catch(error => {
console.error(error);
process.exit(1);
});
You can also check a full project seed in the Examples directory of this repository.
Follow the Usage Guide for the basic boilerplate and a sample project configuration with Database and user authentication samples.
Internal components:
- Logger (backed by winston)
- Database (backed by Mongoose)
- Router (backed by Express)
- Controllers: Classes for handling API calls with decorators and async/await support
- Filters: Middlewares for body validation, permission handling and other interception routines
- Responses:: Simple wrappers over
res.status(code).json(result)
for success and error responses.
External components available as built-in middlewares:
- OAuth 2.0 (express-oauth2-server)
- Sentry (RavenJS)
- CORS (express/cors)
- Multipart (express/multer)
- User Agent (express-useragent and request-ip)
- Body Parser (express/body-parser)
- Method Override (express/method-override)
- Cookie Parser (express/cookie-parser)
Other external plugins and middlewares for this framework
-
Handles API versioning using HTTP Headers.
-
Handles transactional notifications using SMTP (email templates) and Firebase Messaging (push notifications).
-
Advanced usage plugin for handling Schema migrations safely within production environments.
-
Socket.io layer over the TS-Framework. Currently in public alpha.
-
ts-framework-queue (coming soon)
Redis based task rotation queue services. Currently in closed alpha.
-
ts-framework-cache (coming soon)
Redis based cache services for performance. Currently in closed alpha.
-
ts-framework-sql (coming soon)
MySQL / Postgres database layer based on Sequelize. Currently in closed alpha.
Checkout the rendered TS Docs in the official page: https://devnup.github.io/ts-framework/
To generate the Typedoc reference of the available modules directly from source, run the following command:
yarn run docs
Then check the documentation at ./docs/index.html
.
The project is licensed under the MIT License.