Skip to content

Commit

Permalink
chore: update express template
Browse files Browse the repository at this point in the history
  • Loading branch information
joshamaju committed Nov 18, 2024
1 parent d69833b commit f2e9621
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions templates/express/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SESSION_SECRET=_Users_joshuaamaju_Desktop_GitHub_Orgs_the_lean_web_mpa_templates_express_node_modules_express-session_index
4 changes: 2 additions & 2 deletions templates/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
},
"keywords": [],
"dependencies": {
"@stack54/express": "^0.0.2",
"@stack54/express": "^1.0.1",
"body-parser": "^1.20.2",
"compression": "^1.7.4",
"express": "^4.19.2",
"express-session": "^1.18.0",
"method-override": "^3.0.0",
"morgan": "^1.10.0",
"stack54": "^0.5.2",
"stack54": "^0.8.0",
"svelte": "^4.2.8"
},
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions templates/express/src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import methodOverride from "method-override";

import logger from "morgan";

import { register } from "@stack54/express/render";
import { engine, View } from "@stack54/express/view";

import { render } from "./utils/view";
import { resolver } from "./utils/view";
import { errorHandler } from "./error";

const app = express();

register(app, render);
app.engine("svelte", engine);
app.set("view engine", "svelte");
app.set("view", View({ resolve: resolver }));

app.use(logger("dev"));

Expand Down
8 changes: 4 additions & 4 deletions templates/express/src/utils/view.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { makeFactory, resolveComponent } from "stack54/render";
import { resolve_component } from "stack54/render";
import { type TemplateModule } from "stack54/types";

const components = import.meta.glob<TemplateModule>("../views/**/*.svelte");

export const render = makeFactory((name) => {
return resolveComponent(`../views/${name}.svelte`, components);
});
export const resolver = (name: string) => {
return resolve_component(`../views/${name}.svelte`, components);
};
4 changes: 2 additions & 2 deletions templates/express/src/views/components/document.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Head, HotReload } from "stack54/components";
import { Head, LiveReload } from "stack54/components";
</script>

<!DOCTYPE html>
Expand All @@ -17,7 +17,7 @@
/>

<Head />
<HotReload />
<LiveReload />

<slot name="head" />
</head>
Expand Down

0 comments on commit f2e9621

Please sign in to comment.