1.0.10 • Published 3 years ago

tuos-api v1.0.10

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

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