0.1.4 • Published 4 years ago

@via-profit-services/server v0.1.4

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

Via Profit Server service

Install

$ yarn add '@via-profit-services/server'

Usage

import ServerService, { ServerConfig } from '@via-profit/server-service';
import { Router, Response, Request } from 'express';

// Create common server configuration
const config: ServerConfig = {
  apiVersion: 'v1',
  limit: '50mb',
  timezone: 'Asia/Yekaterinburg',
  gzip: {
    level: -1,
  },
};

// Configure Express router
const router = Router();

// then path «/list» would be transform to «/api/v1/list»
router.get('/list', (req: Request, res: Response) => {
  res.json([
    {
      name: 'Foo',
    },
    {
      name: 'Bar',
    },
  ]);
});

const app = ServerService.createApp(config, router);

ServerService.startListener(app, 3001);

// output in console --> App running on port «:XXXX»
0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago