Skip to content

Commit

Permalink
sorting out
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianaf committed Jul 30, 2022
1 parent 184f47c commit 2ab0b06
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions api-01/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,26 @@ app.use(cors(corsOptions));
app.use(auth);
app.use(express.json()); // for parsing application/json
//app.use(express.urlencoded({ extended: true }));
toInteger(process.env.API_LOG)
? app.use(
morgan(morganOptions, {
stream: fs.createWriteStream(log.filePath, { flags: "a" }),
})
)
: null;
app.use(helmet());
app.use(morgan(morganOptions));

toInteger(process.env.API_CREATE_ADMIN) === 1 &&
(async () => {
try {
const user = await service.createfirstUser();
console.log(`First user created succesfully ${user}`);
} catch (error) {
console.log(`Error creating first user: ${error}`);
}
})();

toInteger(process.env.API_LOG) === 1 &&
app.use(
morgan(morganOptions, {
stream: fs.createWriteStream(log.filePath, { flags: "a" }),
})
);

/***
* Routes
*/
Expand All @@ -59,16 +69,6 @@ app.post("/db-check", async (req, res) => {
}
});

toInteger(process.env.API_CREATE_ADMIN) === 1 &&
(async () => {
try {
const user = await service.createfirstUser();
console.log(`First user created succesfully ${user}`);
} catch (error) {
console.log(`Error creating first user: ${error}`);
}
})();

routerAPI(app);

app.listen(process.env.API_PORT, () => {
Expand Down

0 comments on commit 2ab0b06

Please sign in to comment.