README
Welcome to skies 👋
Homepage
🏠Install
npm install skies
Development
index.js
const server = require('skies').server
const LoginController = require('./LoginController')
new LoginController('/login')
server.listen(3000)
LoginController.js
'get' method will responsive for the GET request and the 'post' for the POST, related to the route, that you give as param in constructor, here it's '/login'
const Controller = require('skies').Controller
class LoginController extends Controller {
constructor(route) {
super(route)
}
get(req, res) {
/* This mehtod will process GET request */
res.send('This is get')
}
post(req, res) {
/* This mehtod will process POST request */
res.send({ data: 'This is post, sent by json' })
}
}
module.exports = LoginController
Middlewares
server.use(Path, Function) If middleware returns true, it means it calls other middlware, until it gets to the main function, otherwise if you don't return anything or return false, it will stop, so you cant send some error message or something
function cors(req, res) {
res.writeHead(200, {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Methods': '*'
})
return true
}
server.use('/', cors);
Documentation
/* Returns all params */
req['POST']
req['GET']
/* Returns name param */
req['POST']['name']
req['GET']['name]'
/* Sends response */
res.send('Hi there!')
res.send({hi: "there!"})
/* Returns cookies */
req['cookies']
/* Creates cookies */
res.setCookie(key, value, options)
options = {
maxAge: maxAge
}
Author
👤 Vladislav Kruglikov
- Github: @JadenIT
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2020 Vladislav Kruglikov.
This project is ISC licensed.
This README was generated with ❤️ by readme-md-generator