Small, simple express.js extension built in TypeScript that helps you develop your project with clean and straightforward architecture
Example project index.ts file where we define our server:
Let me explain the building process.
Every express server related things as: routes, middleware etc. will be based on given class that extends ExpressBase interface.
in init function app: Express instance must be created!
this.app = express;
Janpa server calls init function, checks if app is created, adds decorated controller routes to app router and finally calls start method.
Janpa server adds routes to app between init and start call so make sure that you don't add that not found route inside init method because it will override your routes.
.registerService(callback : (c: ServiceRegister) => any)
Adds services to janpa server dependency injection container - use as shown above in code, more on this later.
.registerController(callback: (c: ControllerRegister) => any)
Janpa server keeps track of all added controllers - It is needed to make route decorators work.
Janpa server calls given express base instance start method.
Why janpa-js makes your express project better?
Answer is simple - clean architecture. By using janpa-js your project structure is simpler.
Example suggested project structure:
- index.ts /src /controller - UserController.ts /service - UserService.ts /model - User.ts
All added services to janpa server can be accessed by @Service() decorator inside your controller.
You can use built in controller path decorator like:
I know a lot of things are missing and somethings can be done much better but it is version 0.0.x so pls be patient. I'm still working on it 😎
If you somehow decide to use this tool and you have trouble using it you can contact me on
- Discord: Bajtek#6677
- Email: Bartekkur1@gmail.com