1.1.7 ā€¢ Published 4 years ago

skies v1.1.7

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

šŸ  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

šŸ¤ 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

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago