xcofey

A framework to create apis, based in express

Usage no npm install needed!

<script type="module">
  import xcofey from 'https://cdn.skypack.dev/xcofey';
</script>

README

Logo

XCofey

Make you developer life easier with this lib

Based in express, this lib is aimed at those who want something quick and easy, when it comes to developing APIs!

Getting started

First you need to install the lib

npm logo
hello@world:~$ npm i xcofey

or

yarn logo
hello@world:~$ yarn add xcofey

Basics

Server

const { CreateServer } = require('xcofey');

CreateServer({
  port: 3000,
  controllers: [],
});

Controller (routes)

const { CreateController, Get, HttpError, HttpStatus } = require('xcofey');

const sayHelloWordRoute = Get('/hello', (req, res, next) => {
  try {
    return res.send('Hello Word!');
  } catch(error) {
    next(new HttpError(HttpStatus.INTERNAL_SERVER_ERROR, 'unexpected error');
  }
});

module.exports = CreateController('/', [sayHelloWordRoute]);

Docs -> coming soon