import express, {Express, json} from 'express';
import 'dotenv/config';
import cors from 'cors';
import {connect} from 'mongoose';
import categoryRouter from './routes/Category';
import locationRouter from './routes/Location';
import productRouter from './routes/Product';

const app: Express = express();
app.use(json());
app.use(cors());
app.use('/categories', categoryRouter);
app.use('/locations', locationRouter);
app.use('/products', productRouter);

const run = async () => {
	await connect(`${process.env.MONGO_URL}/office`);
};

run().catch((err) => console.log(err));

app.listen(process.env.PORT, () => {
	console.log('Server started on port ' + process.env.PORT);
});
