1.0.71 • Published 2 years ago

@torr7s/express-base v1.0.71

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Express Application Base

A personal template for instantiating an application with express

Demonstration

import { Application, Logger } from '@torr7s/express-base';

function bootstrap() {
  try {
    const server = new Application({
      port: 8080,
      enableUrlEncoded: true,
      routers: [
        /* List of routers */
      ],
      middlewares: [
        /* Optional list of middlewares */
      ]
    })
    
    server.setup()

    server.start()

  } catch (error) {
    Logger.error(
      `An error has been found during server initialization: ${error}`
    )
  }
}

bootstrap() /* Server is running successfully on port 8080 */
import { AppError } from '@torr7s/express-base';

interface Users {
  name: string;
  age: number;
}

class CreateUserService {
  private _users: Users[] = []

  async perform(name: string) {
    const userExists = this._users.some((user) => user.name === name) 

    if (userExists) throw new AppError('User already exists!', /* optional status code */ 400)

    /* ... */
  }
}
1.0.71

2 years ago

1.0.7

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.6

2 years ago

1.0.51

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago