1.0.71 • Published 3 years ago

@torr7s/express-base v1.0.71

Weekly downloads
-
License
MIT
Repository
github
Last release
3 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

3 years ago

1.0.7

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.6

3 years ago

1.0.51

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago