tuos-api

Tuos API

Usage no npm install needed!

<script type="module">
  import tuosApi from 'https://cdn.skypack.dev/tuos-api';
</script>

README

tuos-api

Tuos API

Installation

# NPM
npm i tuos-api

Usage

server.js

require("dotenv").config();
const fastify = require("fastify")({ logger: true });

fastify.register(require("tuos-api").plugin, {
    jwt_token: "SECRET_TOKEN",
    mongo_host: "mongodb://localhost/test-01",
});

const start = async () => {
    const PORT = 8080;
    const HOST = "0.0.0.0";
    await fastify.ready();
    await fastify
        .listen(PORT, HOST)
        .then((addr) => {
            console.log(`[SYSTEM] Server listening on ${addr}`);
        })
        .catch((err) => {
            fastify.log.error(err);
            console.log("[SYSTEM] Failed to start server! exiting...");
            process.exit(1);
        });
};

start();

Run server.js with node

node server

or with nodemon

nodemon server