Some Update
This commit is contained in:
40
README.md
40
README.md
@@ -1,38 +1,6 @@
|
|||||||
# create-svelte
|
# Food Decisive
|
||||||
|
|
||||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
## Description
|
||||||
|
This is a simple web application that helps users decide what to eat. The user can input their location and the type of food they are craving, and the app will return a list of restaurants that match the user's criteria. The user can then click on a restaurant to view more information about it, such as the restaurant's address, phone number, and website. The app also provides a map with directions to the restaurant.
|
||||||
|
|
||||||
## Creating a project
|
## Technologies Used
|
||||||
|
|
||||||
If you're seeing this, you've probably already done this step. Congrats!
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# create a new project in the current directory
|
|
||||||
npm create svelte@latest
|
|
||||||
|
|
||||||
# create a new project in my-app
|
|
||||||
npm create svelte@latest my-app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Developing
|
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
To create a production version of your app:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
You can preview the production build with `npm run preview`.
|
|
||||||
|
|
||||||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
export default class APISession {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.sessions = new Map();
|
|
||||||
}
|
|
||||||
|
|
||||||
generateSessionID() {
|
|
||||||
let id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
createSession(id) {
|
|
||||||
if(this.sessions.get(id)) return false;
|
|
||||||
this.sessions.set(id, this.generateSessionID());
|
|
||||||
return this.sessions.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSession(id) {
|
|
||||||
for (let [key, value] in this.sessions) {
|
|
||||||
if (key == id) return value;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSession(id, value) {
|
|
||||||
if (!this.sessions.get(id)) return false;
|
|
||||||
this.sessions.set(id, value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
getSessionUser(sessionValue) {
|
|
||||||
for (let [key, value] of this.sessions) {
|
|
||||||
if (value == sessionValue) return key;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteSessionValue(id, key) {
|
|
||||||
if (!this.sessions.get(id)) return false;
|
|
||||||
this.sessions.delete(key);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,8 @@ const MongoServer = new Mongo(process.env.MONGO_URI);
|
|||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.set("mongo", MongoServer);
|
app.set("mongo", MongoServer);
|
||||||
|
|
||||||
|
let routePaths = [];
|
||||||
|
|
||||||
async function loadFolder(filePath) {
|
async function loadFolder(filePath) {
|
||||||
let files = [];
|
let files = [];
|
||||||
fs.readdirSync(filePath).forEach(file => {
|
fs.readdirSync(filePath).forEach(file => {
|
||||||
@@ -34,6 +36,7 @@ async function loadFiles(filePath) {
|
|||||||
if (file.default) {
|
if (file.default) {
|
||||||
let route = new file.default();
|
let route = new file.default();
|
||||||
app.use(route.path, route.getRouter());
|
app.use(route.path, route.getRouter());
|
||||||
|
routePaths.push(route.path);
|
||||||
console.log(`Loaded ${route.path}`);
|
console.log(`Loaded ${route.path}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +61,7 @@ try {
|
|||||||
}, ms('1s'));
|
}, ms('1s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
server.listen(process.env.PORT, () => {
|
server.listen(process.env.PORT, () => {
|
||||||
console.log(`listening on port http://localhost:${process.env.PORT}`);
|
console.log(`listening on port http://localhost:${process.env.PORT}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user