Giter Site home page Giter Site logo

1ronman / snapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urania-dev/snapp

0.0 0.0 0.0 609 KB

Yet Another Url Shortner. A simple excercise to learn Svelte, Svelte5 Runes, and Tabler.

License: Other

JavaScript 0.76% TypeScript 21.60% HTML 35.03% Dockerfile 0.22% Svelte 42.39%

snapp's Introduction

Snapp

Discover the power of Snapp, your self-hostable URL shortening service. Effortlessly shorten links, and with Snapp's self-hosting capability, you have complete control. Create concise, shareable links on your terms with Snapp's user-friendly platform.

A simple excercise to learn Svelte, Svelte5 Runes, and Tabler.

And to host my urls too.

The demo will be resetting every 24H.

Changelog

Since this is a hobby, and i'm still learning, the way of github are obscure to me, so I introduced a change-log, to see if there has been any change on this project recently.

You can find it here

Manual Install / Local Development

You need to have Node.js installed on your machine.

  • Clone the repository or download the latest zip.
  • Download and paste MaxMind geolite-2-city.mmdb into src/lib/server/geo-db/ folder.
  • Copy .example.env to .env and fill it properly.
  • Install dependencies: npm install --legacy-peer-deps.
  • Run for development: npx prisma db push.
  • Run for development: npm run dev.
  • Run for production: npm run build then node -r dotenv/config build.

Admin credentials

By default the app will not create any admin user, you should setup your own by signin up on the front-end. First user registered get marked as Admin.

Also you can set up variables to create admin if not already existing by the same username at platform launch.

SMTP Transporter

Here a resend / generic example of using the SMTP for password recovery. It will check username and mail inserted to be correct before sending.

  • SMTP_HOST=smtp.resend.com
  • SMTP_USER=resend
  • SMTP_PASSWORD={RESEND_API_KEY HERE}
  • SMTP_FROM="No Reply <noreply@{RESEND VERIFIED DNS HERE}.com>"

Docker Install

docker run -p 3000:3000 uraniadev/snapp:latest

Persistance is granted by binding a volume to local file

docker run -p 3000:3000 -v /home/user/snapp/db.sqlite:/app/prisma/db.sqlite uraniadev/snapp:latest

If your run into CORS problem be sure to set ORIGIN and PUBLIC_URL

docker run \
-e ORIGIN=https://example.com \
-e PUBLIC_URL=https://example.com \
-p 3000:3000 \
uraniadev/snapp:latest

CORS and non HTTPS Instances

Snapp uses Lucia Auth, and requires to be hosted behind a Secure HTTPS Protocol.

If self-hosting without a Secure HTTPS Protocol, set NODE_ENV=development to allow Lucia handle sessions.

Let's say for example that you want to host Snapp on an old salvaged homelab with hostname: refurbished on port 8000

docker run \
-p 8000:3000 \
-e ORIGIN=http://refurbished:8000 \
-e PUBLIC_URL=http://refurbished:8000 \
-e NODE_ENV=development \
uraniadev/snapp:latest

Docker-Compose

version: '3'
services:
  snapp:
    restart: always
    container_name: snapp
    image: 'uraniadev/snapp:latest'
    volumes:
      - /docker/snapp/db.sqlite:/app/prisma/db.sqlite
    ports:
      - '3000:3000'
    environment:
      PUBLIC_URL: https://example.com
      ORIGIN: https://example.com
      SMTP_HOST: mail.example.com
      SMTP_USER: [email protected]
      SMTP_PASSWORD: SuperSecurePassword
      SMTP_FROM: [email protected]
      UMAMI_URL: https://umami.example.com
      WEBSITE_ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
      ENABLE_MULTIUSER: false
      DISABLE_HOME: true
      VIRUSTOTAL_API_KEY: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

API REST Interface

Built-in Api endpoints and OpenApi Documentation via Redoc-Static at /openapi.html

Umami Integrations

Yeah my metrics are cool, and integrated, but if you want to have more control, and leverage the power of a real metrics Analytics provider, you can pass

UMAMI_URL set to your Umami instance or cloud.

WEBSITE_ID provided by Umami.

And that should also works in the snapp server-side redirect, as i set a script to send a /api/post request with a payload filled at my best

AdminCLI Utility

Since the db has slightly changed from previous version I released also a little cli Commander interface that will allow to promote or demote users by username. Be aware that the cli operates with full privileges.

You run the interface via docker exec

  # Launch the shell loading aliases
  docker exec -it <container_name> ash -l

  # Use admincli
  admicli help
Usage: admincli [options] [command]

CLI Interface to promote a Snapp User to Admin and SuperAdmin

Options:
  -V, --version                 output the version number
  -h, --help                    display help for command

Commands:
  promote [options] <username>  Promote an user
  demote [options] <username>   Demote an user
  help [command]                display help for command

Basic Usage

Promote a user

  admincli help promote
Usage: admincli promote [options] <username>

Promote an user

Arguments:
  username                   The Snapp registered username of the user you want to promote

Options:
  --role [admin|superadmin]  Specify the role to promote the user to (default: "admin")
  -h, --help                 display help for command

Demote a user

  admincli help demote
Usage: admincli demote <username>

Demote an user

Arguments:
  username                            The Snapp registered username of the user you want to demote

Options:
  -h, --help                          display help for command

Example of usage

  admincli promote user --role superadmin
[user] has been promoted to <role>.

Troubleshooting

If admincli gets not recognize by the container try source the aliases with . ~/.profile or launch the commander cli script at /app/commander/admincli.cjs with node

# change 
admincli help 

# with
node /app/commander/admincli.cjs help

Multi User

Snapp supports also multi-users, just enable with ENABLE_MULTIUSER=true.

DISCLAIMER

The public instance of https://snapp.li and https://demo.snapp.li track anonymous analytics with umami.is.

snapp's People

Contributors

archraziel88 avatar urania-dev avatar hutch79 avatar jeffjose avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.