server: enable sqlite3 database and document env vars

This commit is contained in:
Max Leiter 2022-03-20 23:09:38 -07:00
parent c57e0d6692
commit e2c5e2dac9
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
4 changed files with 26 additions and 8 deletions

View file

@ -21,6 +21,23 @@ You can run `yarn dev` in either / both folders to start the server and client w
If you're deploying the front-end to something like Vercel, you'll need to set the root folder to `client/`. If you're deploying the front-end to something like Vercel, you'll need to set the root folder to `client/`.
### Environment Variables
You can change these to your liking.
`client/.env`:
- `API_URL`: defaults to localhost:3001, but allows you to host the front-end separately from the backend on a service like Vercel or Netlify
- `WELCOME_CONTENT`: a markdown string (with \n newlines) that's rendered on the home page
- `WELCOME_TITLE`: the file title for the post on the homepage.
`server/.env`:
- `PORT`: the default port to start the server on (3000 by default)
- `ENV`: can be `production` or `debug`, toggles logging
- `JWT_SECRET`: a secure token for JWT tokens. You can generate one [here](https://www.grc.com/passwords.htm).
- `MEMORY_DB`: if "true", a sqlite database will not be created and changes will only exist in memory. Mainly for the demo.
## Current status ## Current status
Drift is a major work in progress. Below is a (rough) list of completed and envisioned features. If you want to help address any of them, please let me know regardless of your experience and I'll be happy to assist. Drift is a major work in progress. Below is a (rough) list of completed and envisioned features. If you want to help address any of them, please let me know regardless of your experience and I'll be happy to assist.
@ -34,7 +51,7 @@ Drift is a major work in progress. Below is a (rough) list of completed and envi
- [ ] SSO via HTTP header (Issue: [#11](https://github.com/MaxLeiter/Drift/issues/11)) - [ ] SSO via HTTP header (Issue: [#11](https://github.com/MaxLeiter/Drift/issues/11))
- [x] downloading files (individually and entire posts) - [x] downloading files (individually and entire posts)
- [ ] password protected posts - [ ] password protected posts
- [ ] sqlite database (should be very easy to set-up; the ORM is just currently set to memory for ease of development) - [x] sqlite database
- [ ] non-node backend - [ ] non-node backend
- [ ] administrator account / settings - [ ] administrator account / settings
- [ ] docker-compose (PR: [#13](https://github.com/MaxLeiter/Drift/pull/13)) - [ ] docker-compose (PR: [#13](https://github.com/MaxLeiter/Drift/pull/13))

1
server/.gitignore vendored
View file

@ -1,3 +1,4 @@
.env .env
node_modules/ node_modules/
dist/ dist/
drift.sqlite

View file

@ -1,8 +1,9 @@
import {Sequelize} from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
export const sequelize = new Sequelize({ export const sequelize = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',
database: 'movies', database: 'drift',
storage: ':memory:', storage: process.env.MEMORY_DB === "true" ? ":memory:" : __dirname + './../drift.sqlite',
models: [__dirname + '/models'] models: [__dirname + '/models'],
host: 'localhost',
}); });

View file

@ -4,8 +4,7 @@ import config from '../lib/config';
import { sequelize } from '../lib/sequelize'; import { sequelize } from '../lib/sequelize';
(async () => { (async () => {
await sequelize.sync({ force: true }); await sequelize.sync();
createServer(app) createServer(app)
.listen( .listen(
config.port, config.port,