New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@scripty/server

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scripty/server

wrapper for express server.

latest
Source
npmnpm
Version
0.3.5
Version published
Maintainers
1
Created
Source

@scripty/server

Description

Setting up a node server for a website can be a pain. This express wrapper will install and preconfigure many dependencies with which you can run a one page application in react. Admittedly, not every use case is covered but that actually wasn´t the goal. The main goal was to keep it easy and clean.

Features:

  • prerendering (no server side rendering)
  • compression
  • body parsing
  • favicon middleware
  • webpack-hot-middleware for hot modules reloading
  • preconfigured static paths
  • initialized routing

Usage

npm install -s @scripty/server
Client: server.js
import { Server, IndexController } from '@scripty/server';

const init = async () => {
    let app = new Server();
    await app.addController(new IndexController({ title: 'For title tag' }));
    await app.addController(new ExampleController());
    app.start(3000);
};

init().catch((err) => {
    console.error(err.message);
});

Client: ExampleController.js
export class ExampleController {
    init(server, router) {
        router.post('/create', this.createAction);
        router.get('/read', this.readAction);
        server.use(router);
    }

    createAction(req, res) {
        res.json({example: 'foo'})
    };

    readAction(req, res) {
        res.json({example: 'foo'})
    };
}

Static Files

if you want to access your static files you have to create following folders in your project:

project
│   README.md
│   file001.txt
│
└───public
│   │
│   │
│   │
│   └───images
│   │    │   image1.png
│   │    │   image2.jpg
│   │    │   ...
│   │
│   └───files
│   │    │   file1.txt
│   │    │   file2.zip
│   │    │   ...

You can access your files on server this way:

https://localhost:3000/files/file1.txt

https://localhost:3000/images/image1.png

What´s next?

  • add possibility to configure meta data
  • extending readme

Keywords

express.js

FAQs

Package last updated on 02 Aug 2020

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