List, export, recommendations done
This commit is contained in:
16
app.ts
16
app.ts
@@ -8,21 +8,22 @@ import * as path from "path";
|
||||
import * as read from "read-file";
|
||||
import * as uuidv4 from "uuid/v4";
|
||||
|
||||
import * as exportRouter from "./routes/export";
|
||||
import * as indexRouter from "./routes/index";
|
||||
import * as recommendsRouter from "./routes/recommends";
|
||||
import * as updateRouter from "./routes/update";
|
||||
import * as usersRouter from "./routes/users";
|
||||
|
||||
const app = express();
|
||||
const adapter = new FileSync("db.json")
|
||||
const db = low(adapter);
|
||||
app.db = db;
|
||||
(app as any).db = db;
|
||||
db.defaults({users: []})
|
||||
.write();
|
||||
|
||||
|
||||
|
||||
|
||||
app.cocktails = [];
|
||||
(app as any).cocktails = [];
|
||||
|
||||
read("data/output.csv", "utf8", (err, buffer) => {
|
||||
// console.log(buffer);
|
||||
@@ -41,8 +42,8 @@ read("data/output.csv", "utf8", (err, buffer) => {
|
||||
return line;
|
||||
});
|
||||
result = result.filter((f) => !!f);
|
||||
app.cocktails = result;
|
||||
app.cocktailList = cocktailList;
|
||||
(app as any).cocktails = result;
|
||||
(app as any).cocktailList = cocktailList;
|
||||
});
|
||||
|
||||
|
||||
@@ -63,7 +64,7 @@ app.use((req, res, next) => {
|
||||
db.get("users")
|
||||
.push({id, age: -1, sex: "na", cocktails: [], lastused: Date.now()})
|
||||
.write();
|
||||
res.cookie("uid", id, { maxAge: 21474836470000, httpOnly: true });
|
||||
res.cookie("uid", id, { maxAge: 21474836470000/*, httpOnly: true*/ });
|
||||
if (!req.cookies) {
|
||||
req.cookies = {};
|
||||
}
|
||||
@@ -79,8 +80,9 @@ app.use((req, res, next) => {
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
|
||||
app.use("/", indexRouter);
|
||||
app.use("/users", usersRouter);
|
||||
app.use("/export", exportRouter);
|
||||
app.use("/update", updateRouter);
|
||||
app.use("/recommends", recommendsRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use((req, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user