0.0.5 • Published 7 years ago

yuma v0.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Yuma

A simple, configurable node and express based server

You can have a Yuma server with cors enabled, allowing json content, using http or https or both within a minute.

Installing

Install Yuma via npm:

npm i -S yuma

Once, Yuma is installed, it will create a public folder with an index.html file and an assets folder inside your project's root directory. You can easily replace the index.html with your own content.

Starting the server

To start the Yuma server with the default settings, just add the following script to your package.json...

"scripts": {
    "start": "yuma start"
}

Once you are done adding the script to your package.json, open your command line in your project's root directory and type:

npm start

The Yuma server will start and your default browser will launch with the Yuma website. The server's defaults settings are:

  • http
  • cors enabled to every domain
  • accepts json

Configuring Yuma

You can configure your Yuma server by creating a yuma.config.js in your project's root folder. The config file looks like this:

module.exports = {
    host: 'localhost',
    json: true,
    cors: {
        origin: '*',
        methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
        preflightContinue: false,
        optionsSuccessStatus: 204
    },
    http: {
        port: '80',
    },
    https: {
        port: '443',
        credentials:{
            key: fs.readFileSync('./path/to/your/key/pem'),
            cert: fs.readFileSync('./path/to/your/cert/pem')
        }
    },
    directories: [{
        path: path.join(process.cwd(), 'public'),
        virtual: ''
    }]
};

Any of the properties omitted will turn that function off. For example if you do not need https then do not add the https property to your yuma.config.js file.

Gotchas

  • To run your Yuma server on port 80 you need to run the yuma start command under your root account.
  • Creating a certificate for your Yuma's https server:
    • open your command line - for windows, use git bash or cygwin and read the following article: create a self signed certificate
    • type: openssl genrsa -out key.pem
    • type : openssl req -new -key key.pem -out csr.pem
    • type: openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
    • finally type: rm csr.pem
0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago