0.0.21 • Public • Published


    Small, simple express.js extension built in TypeScript that helps you develop your project with clean and straightforward architecture

    Basic usage

    Example project index.ts file where we define our server:

        .registerService(server  => {
        .registerController(server  => {

    Let me explain the building process.

    .addExpressBase(app: ExpressBase)

    Every express server related things as: routes, middleware etc. will be based on given class that extends ExpressBase interface.

    interface ExpressBase {
        app: Express;
        init(): Promise<Express>;
        start(): Promise<any>;

    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.

    export  class  ExpressServer  implements  ExpressBase {
        app: Express;
        async  init(): Promise<any> {
            this.app = express();
            this.app.use((req, res: Response, next) => {
            res.header("Access-Control-Allow-Origin", "*");
        async  start()Promise<any> {
            this.app.use(async (req: Request, res: Response) => {
            this.app.listen(conf.PORT, conf.HOST_NAME, 0, () => {
                console.log(`Express server is running on ${conf.HOST_NAME}:${conf.PORT}`);

    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
    		- UserController.ts
    		- UserService.ts
    		- User.ts

    All added services to janpa server can be accessed by @Service() decorator inside your controller.

    export  class  UserController {
        private  userService: UserService;
        private  async  register(req: Request, res: Response): Promise<void> {
            try {
            } catch(e) {

    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


    npm i janpa-js

    DownloadsWeekly Downloads






    Unpacked Size

    17 kB

    Total Files


    Last publish


    • bartekkur1