How to use the morgan.default function in morgan

To help you get started, we’ve selected a few morgan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimmyleray / Emendare / server / src / index.ts View on Github external
// Global configuration
const port: number = Number(process.env.PORT) || 3000;
const gitlabAPIUrl: string = "https://gitlab.com/api/v4";

// Http promise requests
import * as axios from "axios";

// Express Html Application
import * as express from "express";
const app: express.Application = express.default();

// Requests Logger Middleware
import * as morgan from "morgan";
app.use(morgan.default("tiny"));

// Function to add API Url to a partial path
const api = (path: string) => gitlabAPIUrl + path;

// Open API CORS Headers
app.use(
  (req: express.Request, res: express.Response, next: express.NextFunction) => {
    res.header("Access-Control-Allow-Origin", "*");
    next();
  }
);

// Get a specific group with subgroups
app.get("/groups/:id", (req: express.Request, res: express.Response) => {
  Promise.all([
    axios.default.get(api(`/groups/${req.params.id}`)),

morgan

HTTP request logger middleware for node.js

MIT
Latest version published 5 years ago

Package Health Score

81 / 100
Full package analysis