Server db utils changes
This commit is contained in:
parent
91e99e1bcc
commit
d86ebe3e58
5 changed files with 36 additions and 21 deletions
24
README.md
24
README.md
|
@ -7,19 +7,13 @@
|
|||
Flame is self-hosted startpage for your server. Its design is inspired (heavily) by [SUI](https://github.com/jeroenpardon/sui). Flame is very easy to setup and use. With built-in editors, it allows you to setup your very own application hub in no time - no file editing necessary.
|
||||
|
||||
## Functionality
|
||||
📝 Create, update, delete your applications and bookmarks directly from the app using built-in GUI editors
|
||||
|
||||
📌 Pin your favorite items to the homescreen for quick and easy access
|
||||
|
||||
🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own
|
||||
|
||||
🔑 Authentication system to protect your settings, apps and bookmarks
|
||||
|
||||
🔨 Dozens of option to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes
|
||||
|
||||
☀️ Weather widget with current temperature, cloud coverage and animated weather status
|
||||
|
||||
🐳 Docker integration to automatically pick and add apps based on their labels
|
||||
- 📝 Create, update, delete your applications and bookmarks directly from the app using built-in GUI editors
|
||||
- 📌 Pin your favorite items to the homescreen for quick and easy access
|
||||
- 🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own
|
||||
- 🔑 Authentication system to protect your settings, apps and bookmarks
|
||||
- 🔨 Dozens of option to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes
|
||||
- ☀️ Weather widget with current temperature, cloud coverage and animated weather status
|
||||
- 🐳 Docker integration to automatically pick and add apps based on their labels
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -55,7 +49,7 @@ docker buildx build \
|
|||
|
||||
```sh
|
||||
# run container
|
||||
docker run -p 5005:5005 -v /path/to/data:/app/data flame
|
||||
docker run -p 5005:5005 -v /path/to/data:/app/data -e PASSWORD=flame_password flame
|
||||
```
|
||||
|
||||
#### Docker-Compose
|
||||
|
@ -124,7 +118,7 @@ npm run dev
|
|||
|
||||
![Settings screenshot](.github/settings.png)
|
||||
|
||||
![Themes screenshot](.github/_themes.png)
|
||||
![Themes screenshot](.github/themes.png)
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
const { Sequelize } = require('sequelize');
|
||||
const { join } = require('path');
|
||||
const Umzug = require('umzug');
|
||||
const backupDB = require('./utils/backupDb');
|
||||
|
||||
// Utils
|
||||
const backupDB = require('./utils/backupDb');
|
||||
const Logger = require('../utils/Logger');
|
||||
const logger = new Logger();
|
||||
|
||||
|
@ -28,15 +29,16 @@ const connectDB = async () => {
|
|||
backupDB();
|
||||
|
||||
await sequelize.authenticate();
|
||||
logger.log('Connected to database');
|
||||
|
||||
// migrations
|
||||
// execute all pending migrations
|
||||
const pendingMigrations = await umzug.pending();
|
||||
|
||||
if (pendingMigrations.length > 0) {
|
||||
logger.log('Executing pending migrations');
|
||||
await umzug.up();
|
||||
}
|
||||
|
||||
logger.log('Connected to database');
|
||||
} catch (error) {
|
||||
logger.log(`Unable to connect to the database: ${error.message}`, 'ERROR');
|
||||
process.exit(1);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const fs = require('fs');
|
||||
const { slugify } = require('./slugify');
|
||||
|
||||
const backupDB = () => {
|
||||
if (!fs.existsSync('data/db_backups')) {
|
||||
fs.mkdirSync('data/db_backups');
|
||||
}
|
||||
|
||||
const version = process.env.VERSION;
|
||||
const slug = `db-${version.replace(/\./g, '')}-backup.sqlite`;
|
||||
const slug = slugify();
|
||||
|
||||
const srcPath = 'data/db.sqlite';
|
||||
const destPath = `data/db_backups/${slug}`;
|
||||
|
|
19
db/utils/slugify.js
Normal file
19
db/utils/slugify.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const slugify = () => {
|
||||
const version = process.env.VERSION;
|
||||
const slug = `db-${version.replace(/\./g, '')}-backup.sqlite`;
|
||||
return slug;
|
||||
};
|
||||
|
||||
const parseSlug = (slug) => {
|
||||
const parts = slug.split('-');
|
||||
const version = {
|
||||
raw: parts[1],
|
||||
parsed: parts[1].split('').join('.'),
|
||||
};
|
||||
return version;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
slugify,
|
||||
parseSlug,
|
||||
};
|
|
@ -20,9 +20,9 @@ const logger = new Logger();
|
|||
const PORT = process.env.PORT || 5005;
|
||||
|
||||
// Init app
|
||||
await initApp();
|
||||
await connectDB();
|
||||
await associateModels();
|
||||
await initApp();
|
||||
|
||||
// Create server for Express API and WebSockets
|
||||
const server = http.createServer();
|
||||
|
|
Loading…
Reference in a new issue