diff options
author | Raphael <mail@raphaelkabo.com> | 2023-10-06 16:54:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-06 16:54:03 +0100 |
commit | a14afed944e5f0b87af96cc5c6a262d246b88d1d (patch) | |
tree | 26104aa7f2717ea7e8f69734a2181d456f264481 /src/app.ts | |
parent | f390b1d45b3f44a860fef4df2b31064f441b5065 (diff) | |
parent | 722d54e5ae8957436818b14e7aea613b19b12d28 (diff) |
Merge pull request #111 from lowercasename/rk/typescript
Typescript migration
Diffstat (limited to 'src/app.ts')
-rwxr-xr-x | src/app.ts | 43 |
1 files changed, 23 insertions, 20 deletions
@@ -1,31 +1,33 @@ import express from "express"; -import routes from "./routes.js"; import hbs from "express-handlebars"; +import routes from "./routes.js"; +import frontend from "./routes/frontend.js"; + const app = express(); // View engine // const hbsInstance = hbs.create({ - defaultLayout: "main", - partialsDir: ["views/partials/"], - layoutsDir: "views/layouts/", - helpers: { - plural: function (number: number, text: string) { - var singular = number === 1; - // If no text parameter was given, just return a conditional s. - if (typeof text !== "string") return singular ? "" : "s"; - // Split with regex into group1/group2 or group1(group3) - var match = text.match(/^([^()\/]+)(?:\/(.+))?(?:\((\w+)\))?/); - // If no match, just append a conditional s. - if (!match) return text + (singular ? "" : "s"); - // We have a good match, so fire away - return ( - (singular && match[1]) || // Singular case - match[2] || // Plural case: 'bagel/bagels' --> bagels - match[1] + (match[3] || "s") - ); // Plural case: 'bagel(s)' or 'bagel' --> bagels + defaultLayout: "main", + partialsDir: ["views/partials/"], + layoutsDir: "views/layouts/", + helpers: { + plural: function (number: number, text: string) { + var singular = number === 1; + // If no text parameter was given, just return a conditional s. + if (typeof text !== "string") return singular ? "" : "s"; + // Split with regex into group1/group2 or group1(group3) + var match = text.match(/^([^()\/]+)(?:\/(.+))?(?:\((\w+)\))?/); + // If no match, just append a conditional s. + if (!match) return text + (singular ? "" : "s"); + // We have a good match, so fire away + return ( + (singular && match[1]) || // Singular case + match[2] || // Plural case: 'bagel/bagels' --> bagels + match[1] + (match[3] || "s") + ); // Plural case: 'bagel(s)' or 'bagel' --> bagels + }, }, - }, }); app.engine("handlebars", hbsInstance.engine); app.set("view engine", "handlebars"); @@ -39,6 +41,7 @@ app.use(express.json({ type: "application/activity+json" })); // support json en app.use(express.urlencoded({ extended: true })); // Router // +app.use("/", frontend); app.use("/", routes); export default app; |