Nonsense Placement Mandatory

    @kth/http-responses

    1.0.77 • Public • Published

    HTTP Responses alt text Continous Integration

    Npm: @kth/http-responses

    Simple ways of returning responses in a declarative way without status codes. Note that it is not async so use it for simple smal stuff.

    Demo application

    Demo code source here.

    const express = require("express");
    const httpResponse = require("@kth/http-responses");
    const app = express();
    
    app.get("/", function (request, response) {
      httpResponse.ok(request, response, "<!DOCTYPE html><h1>Hello world!<h1>");
    });
    
    app.get("/_monitor", function (request, response) {
      httpResponse.ok(
        request,
        response,
        "APPLICATION_STATUS: OK",
        httpResponse.contentTypes.PLAIN_TEXT
      );
    });
    
    app.get("/error5xx.html", function (request, response) {
      httpResponse.internalServerError(request, response, "Internal Server Error");
    });
    
    app.get("/favicon.ico", function (request, response) {
      httpResponse.noContent(request, response);
    });
    
    app.use(function (request, response) {
      httpResponse.notFound(request, response, "Page not found");
    });
    
    app.listen(80, function () {
      console.log("Server started");
    });
    {
      "name": "Demo",
      "version": "1.0.0",
      "description": "Demo app for @kth/http-responses",
      "main": "index.js",
      "scripts": {
        "clean": "rm -r ./node_modules && rm package-lock.json"
      },
      "author": "paddy@kth.se",
      "license": "MIT",
      "dependencies": {
        "@kth/http-responses": "^1.0.20",
        "express": "^4.17.1"
      }
    }

    Keywords

    Install

    npm i @kth/http-responses

    DownloadsWeekly Downloads

    70

    Version

    1.0.77

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • kthwebmaster
    • wkchung
    • exacs
    • ssundkvist
    • kth-ci
    • emilstenberg