Code Monkey home page Code Monkey logo

ronin-starter's Introduction

๐Ÿ™ˆ

๐Ÿ–ฅ๏ธ

ronin-starter's People

Contributors

dependabot[bot] avatar squishy123 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ronin-starter's Issues

Custom Node.js Server

Custom Node.js Server with the following features

  • Seamless WS Support
  • Plugin support
  • Hot Reloading of routes
  • Full async support

Add working jest testing suite config for components

Add working jest testing suite for components

The following changes configure the environment for jest testing

Change package.json to exclude tests from nodemon, add a testing script and prevent jest from transforming files via babel

 "scripts": {
    "dev": "cross-env NODE_ENV=development nodemon --exec babel-node src/server/server.js",
    "format": "prettier --write \"./**/*.{js,jsx,json}\"",
+    "test": "jest"
  },
+  "nodemonConfig": {
+    "verbose": false,
+    "ignore": [
+      "tests/*"
+    ]
+  },
+  "jest": {
+    "transform": {}
+  }

An example test would look like the following:

In file: tests/routes/users/loginUser.test.js

const fetch = require('node-fetch');
//${process.env.SERVER_URL}:${process.env.SERVER_PORT}
async function loginUser(username, email, password) {
    return await fetch(`http://localhost:3000/user/login`,
        {
            method: 'POST',
            body: {
                username, email, password
            }
        }).then(res => res.json());
}

test(`all null values`, () => {
    return loginUser(null, null, null).then(data => {
        console.log(data);
        expect(data).toStrictEqual({
            message: "Error: Missing required parameter username/email and password"
        });
    })
});

*NOTE: Jest runs files containing the string test in its name

Add Global Route Exception Handling

Add Global Route Exception Handling by changing the following in (src/server/modules/routeLoader.js)

function packageMiddle(middle) {
    return async function (req, res, next) {
+        try {
            await middle(req, res);
            if(next) 
                next();
+        } catch(err) {
+            res.status(400).send(err);
+        }
    };
}

Still unsure about having exception handling done globally for each route or having it in each async middleware...

Better Debugging System

Better Debugging System

Currently the ronin-starter uses basic console logging for verbose messages such as:

  • Initialization/Bootup messages (Server startup)
  • Route errors (During runtime)

Since console.log is a synchronous process, large amounts of logging can decrease the performance of the server. Additionally there needs to be a better system to log messages to a file for archival purposes and also in the event of a server failure.

Implementation of a better debugging system is desireable:

Possible Library Inclusions:

NEEDS BRAINSTORMING ๐Ÿง 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.