Crates.io | goxidize |
lib.rs | goxidize |
version | 0.1.1 |
source | src |
created_at | 2021-11-06 11:32:51.555872 |
updated_at | 2022-03-25 01:22:49.080661 |
description | A link shortener |
homepage | https://github.com/caizixian/goxidize |
repository | https://github.com/caizixian/goxidize |
max_upload_size | |
id | 477635 |
size | 287,308 |
A link shortener.
Before building the project, please create a .env
file with a valid PostgreSQL URL, such as the following.
DATABASE_URL=postgresql://localhost:5432/goxidize
Then, run the database migrations.
sqlx migrate run
This database is queried against for compile-time checks done by sqlx
.
If you don't have a database set up, sqlx
will check against sqlx-data.json
.
To generate this file, run cargo sqlx prepare -- --lib
and cargo sqlx prepare --check -- --lib
.
Note that you will still need a working database to run the tests.
The Parcel development server supports auto-reloading for frontend assets. Use the following file to let the Parcel server proxy requests to the backend.
const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
createProxyMiddleware(["/**", "!/", "!**/*.html", "!**/*.js", "!*.css", "!**/*.css", "!**/*.map"], {
target: "http://localhost:8000/",
})
);
};
Run the following to start the servers.
cargo run # use cargo watch for auto-reloading
# then on a separate terminal, run
# `npm install` if you have not installed the dependencies, and
npm start
npm run build
A YAML file is used for configuration. This affects the run-time behaviour of the program.
# configuration.yml
port: 8000
database:
url: postgresql://localhost:5432
name: goxidize
debug: true
An example of deployment using docker-compose
is provided below.
# docker-compose.yml
version: '3'
services:
db:
image: postgres:14
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: goxidize
LANG: C.UTF-8
volumes:
- dbdata:/var/lib/postgresql/data
goxidize:
image: ghcr.io/caizixian/goxidize:master
restart: always
depends_on:
- "db"
ports:
- "8000:8000"
# Using environment variables is another option
volumes:
- "./goxidize_config.yml:/goxidize/configuration.yml"
volumes:
dbdata:
# goxidize_config.yml
host: "0.0.0.0"
port: 8000
database:
host: db
port: 5432
username: postgres
password: password
name: goxidize
debug: false
Except as otherwise noted (e.g., in individual files), the project is licensed under the Apache License, Version 2.0 LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0 or the MIT license LICENSE-MIT or http://opensource.org/licenses/MIT, at your option.