Socket
Book a DemoInstallSign in
Socket

consequaturodio

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consequaturodio

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
1
Created
Source

${pkg.name}

${badge('npm')} ${badge('npm-license')} ${badge('github-issues')}

${pkg.description}

${badge('nodei')}

${badge('travis-status')} ${badge('github-stars')} ${badge('github-forks')}

${badge('github-forks')}

${badge('dependencies')} ${badge('devDependencies')}

Features

  • Configure express application.
  • Written in TS

Usage

lib/app-routes.ts

const siteStarter = require('tsm.name');

import {AppResponse, BasicRoutes} from 'ts-site-starter';
import {Request} from 'express';

export class AppRoutes extends BasicRoutes {
  constructor(basePath: string) {
    super(basePath);
    this.addRoutes();
  }

  homePage(req: Request, res: AppResponse) {
    res.serve('home', {});
  }

  addRoutes() {
    this.router.get('/', this.homePage.bind(this));
  }
}

index.ts

import * as express from "express";
import * as log from 'great-logs';
import { configureRest, serverConfig } from 'ts-site-starter';
import { AppRoutes } from './lib/app-routes';

/**
 * The server.
 * @class Server
 */
export class Server {

  public app: express.Application;

  /**
   * Constructor.
   * @class Server
   * @constructor
   */
  constructor() {
    //create expressjs application
    this.app = express();
    configureRest(this.app, express);
  }

  routeApp() {
    const routes = (new AppRoutes('')).getRoutes();
    this.app.use(routes);
  }

  start() {
    this.routeApp();
    const port = serverConfig.getPort();
    this.app.listen(port, function () {
      log.info('port: %s', port);
      log.info('url: %s', serverConfig.base);
    });
  }
}

// Start the application
new Server().start();

Install

npm install --save ${pkg.name}

Scripts

${scripts()}

Dependencies

${dependencies()}

Contributing

Contributions welcome; Please submit all pull requests against the master branch. If your pull request contains TypeScript patches or features, you should include relevant unit tests. Please check the Contributing Guidelines for more details. Thanks!

Author

${author()}

License

${license()}

Keywords

doloribus

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts