yuma v0.0.5
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
Yumaserver onport 80you need to run theyuma startcommand under yourrootaccount. - Creating a certificate for your
Yuma'shttpsserver:- 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