mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
Merge pull request #673 from Pythagora-io/example-project
improve example project
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from utils.style import color_green_bold
|
||||
from logger.logger import logger
|
||||
@@ -51,6 +52,7 @@ def apply_project_template(
|
||||
{
|
||||
"project_name": project_name,
|
||||
"project_description": project_description,
|
||||
"random_secret": uuid4().hex,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
8
pilot/templates/tpl/node_express_mongoose/.env
Normal file
8
pilot/templates/tpl/node_express_mongoose/.env
Normal file
@@ -0,0 +1,8 @@
|
||||
# Port to listen on (example: 3000)
|
||||
PORT=3000
|
||||
|
||||
# MongoDB database URL (example: mongodb://localhost/dbname)
|
||||
DATABASE_URL=mongodb://localhost/myDb # INPUT_REQUIRED {insert your MongoDB url here}
|
||||
|
||||
# Session secret string (must be unique to your server)
|
||||
SESSION_SECRET={{ random_secret }}
|
||||
@@ -36,7 +36,7 @@ mongoose
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Session configuration with connect-mongo
|
||||
// Session configuration with connect-mongo
|
||||
app.use(
|
||||
session({
|
||||
secret: process.env.SESSION_SECRET,
|
||||
@@ -54,13 +54,15 @@ app.on("error", (error) => {
|
||||
// Logging session creation and destruction
|
||||
app.use((req, res, next) => {
|
||||
const sess = req.session;
|
||||
// Make session available to all views
|
||||
res.locals.session = sess;
|
||||
if (!sess.views) {
|
||||
sess.views = 1;
|
||||
console.log("Session created at: ", new Date().toISOString());
|
||||
} else {
|
||||
sess.views++;
|
||||
console.log(
|
||||
`Session accessed again at: ${new Date().toISOString()}, Views: ${sess.views}`,
|
||||
`Session accessed again at: ${new Date().toISOString()}, Views: ${sess.views}, User ID: ${sess.userId || '(unauthenticated)'}`,
|
||||
);
|
||||
}
|
||||
next();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>A3 Time Tracker</title>
|
||||
<title>{{ project_name }}</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
</head>
|
||||
|
||||
@@ -9,9 +9,12 @@
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<% if (session && session.userId) { %>
|
||||
<a class="nav-link" href="/auth/logout">Logout</a>
|
||||
<% } else { %>
|
||||
<a class="nav-link" href="/auth/login">Login</a>
|
||||
<% } %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user