• This repository has been archived on 16/Feb/2021
  • Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    TypeScript
  • Created almost 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SnailJS - Slow and thoughtful development with Node and React

SnailJS - Slow and thoughtful development with Node and React

SnailJS is a starter/boilerplate app that attempts to define some structure for projects where the people involved want to dedicate some thought into how they will be built, don't want to give up control, and want to be fairly optimized.

Screenshot

It's not very opinionated. It's meant to build an app using Webpack (for dev/prod optimizations), Babel (for the nice import syntax and other ES6+ goodies), a Koa backend, a React frontend, and TypeScript (if you prefer Flow static typing, check the last commit with it), with some common needs like routing, absolute paths, SASS parsing, tests, and build processes.

Other than that, it doesn't force you to specific tech solutions like how to code split, redux, mobx, mustache, mongo, mysql, etc. There are other tools for that kind of opinionated app building like SailsJS.

If you need a simple frontend app, try create-react-app. If you need a bit more complexity (or a "webpacked" node app), Neutrino is pretty good as well. For frontend and backend coupled things I've been enjoying a lot of Next.js.

This really serves the purpose of someone wanting/needing something like SailsJS but without all the magic/opinionated code.

Requirements

node (ideally via nvm, so .nvmrc is respected).

Development

Here's a list of the available commands:

make install  # for getting everything setup
make start  # for dev build. Check if you want to update your `.env.local` file (it's unversioned)
make lint  # to run linting and TypeScript checking
make test  # to run `make lint` and tests
make test/update  # to run `make lint` and tests, updating snapshots
make pretty  # to run `prettier` on all code
make test/pretty  # to check if `prettier` needs to change anything
make build  # for prod build
make test/build  # to run `make build` and serve it locally in production mode
make deploy  # will deploy a server to DigitalOcean with the app (read more below). Make sure to run `make build` first
make deploy/update  # will update the frontend and backend of a deployed server (so `make deploy` has to have been executed first, and make sure to have run `make build`)
make deploy/destroy  # will destroy the infra/server
make deploy/serverless  # will deploy the whole app using `vercel`, in a serverless fashion. Learn more below. Make sure to run `make build` first

Deployment ("cool kids" serverless)

This is using vercel (install via npm i vercel -g) and quite unoptimized, but any other alternatives should be simple to adapt. Also, please note for serverless you might want to split/isolate the frontend and backend to keep things a bit faster, but it's not mandatory.

Deployment ("old school" server)

Note this is a simple deployment setup. It's scalable, but not necessarily following best security practices. Ideally you'll have/use a non-root user, VPNs/VPCs, load balancers, and all that, but you never need that upfront, so this is meant to help get your feet off the ground and into space, not Mars (and it should define a structure to get there when you need to).

Before you run make deploy, set the variables inside the deploy/variables.tf file. Here's a sample with fake data that explains where/how to get them:

variable "do_token" {
  default = "Token From DigitalOcean. Get it at https://cloud.digitalocean.com/account/api/tokens"
}
variable "pub_key" {
  default = "~/.ssh/id_rsa.pub"
}
variable "pvt_key" {
  default = "~/.ssh/id_rsa"
}
variable "ssh_fingerprint" {
  default = "The MD5 Fingerprint from your SSH Key at https://cloud.digitalocean.com/account/security"
}

That assumes DigitalOcean already has your ~/.ssh/id_rsa.pub key in https://cloud.digitalocean.com/account/security.

After you run make deploy you'll be able to ssh root@IP_ADDRESS and cd /app && ./stop.sh, cd /app && ./start.sh, orcd /app && ./restart.sh. Ideally you'll also setup a cron or manually run certbot renew to update the SSL certificates.

If you need to update the app, just run IP=IP_ADDRESS make deploy/update and it'll build the assets, push them over, and restart the server.

First Deployment

There's a couple of manual things you need to do right now for the first time deploying (this can totally be improved with some more dedicated time), like setting up nginx properly and the certificates:

ssh root@IP_ADDRESS

certbot --nginx -d example.com -d www.example.com
# I'd recommend option 2 (redirect HTTP to HTTPS).

nano /etc/nginx/sites-enabled/default
# Add the content below inside the main `server` block, near the bottom, for the `listen 443` piece:
location / {
  proxy_pass http://localhost:3000/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection 'upgrade';
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_cache_bypass $http_upgrade;
}

Now start the app: /app/restart.sh.

More Repositories

1

budgetzen-web

Simple, Encrypted Budgets & Expenses. πŸ’΅
TypeScript
91
star
2

loggit-web

Simple, Encrypted Life Tracking & Logging. πŸ’Š
TypeScript
42
star
3

web3-type-converter

Convert from a bytes32/hex into a string/number or vice-versa.
CSS
22
star
4

deno-boilerplate-simple-website

This is a simple boilerplate for a Deno website, deployed with Deno Deploy. πŸ¦•
TypeScript
19
star
5

standardnotes-folder-export-cli

Standard Notes Folder Export CLI - Deno
TypeScript
13
star
6

nextjs-boilerplate-simple

Simple boilerplate for Next.js, with TypeScript, SASS/SCSS, Styled Components, Jest, ESLint, Prettier, and deployed with Vercel.
TypeScript
11
star
7

ProjQueryPlugins

Code Repository for the Pro jQuery Plugins eBook
JavaScript
8
star
8

shurley

I'll give you the right URL, but don't call me Shirley!
TypeScript
6
star
9

nextjs-boilerplate-faunadb-elasticsearch

Cronjob boilerplate for Next.js using Github Actions for the cleanup/reindex cron. With TypeScript, SASS/SCSS, Styled Components, Jest, ESLint, Prettier, and deployed with Vercel.
TypeScript
6
star
10

1pux-to-csv

This package/script/CLI converts a 1Password .1pux file to a CSV file.
TypeScript
5
star
11

nextjs-boilerplate-blog-markdown

Markdown blog boilerplate for Next.js, with TypeScript, SASS/SCSS, Styled Components, Jest, ESLint, Prettier, and deployed with Vercel.
TypeScript
5
star
12

node-google-cloud-helper

A CLI Node.js helper for Google Cloud
JavaScript
4
star
13

lockdb

LockDB is a cross-platform tool you can use to handle process/event locking and avoid race conditions. It is sometimes also known as a semaphore.
TypeScript
3
star
14

filebox.js

filebox.js is just a simple and personal file hosting system.
JavaScript
2
star
15

budgetzen-mobile

Mobile app for simple budget management.
TypeScript
2
star
16

LiteBox

A Lightweight & Simple jQuery LightBox-like plugin
CoffeeScript
2
star
17

deno-code-examples

This is an app with examples built using Deno.
TypeScript
2
star
18

asksoph

Ask Soph - Soph is a bot that will try to help you understand the work of a list of dead philosophers
TypeScript
1
star
19

budgetzen-desktop

Desktop app for simple budget management.
TypeScript
1
star
20

invisibleCount

This chrome extension will hide stats and counts from Twitter and Medium.
JavaScript
1
star
21

unity-django

Project Manager for Wozia, using Django
CoffeeScript
1
star
22

loggit-mobile

Mobile app for simple unscheduled event management.
TypeScript
1
star
23

Espruino

Code for my experiments with Espruino
JavaScript
1
star
24

Veezy-iOS

No more features being added. Maintained for bug fixes.
Swift
1
star
25

I-m-Driving--Android-

This is the source code made open source for Wozia's I'm Driving Android app. More info on the site below.
Java
1
star
26

Oikon2-Mac

No more features being added. Maintained for new hardware and bugs.
JavaScript
1
star
27

push-zap

Trigger a Zap from the command line.
JavaScript
1
star
28

dejal-timeout-theme-photo-slideshow

Dejal Time Out Theme: Photo Slideshow
HTML
1
star
29

dejal-timeout-theme-nature-photos

Dejal Time Out Theme: Nature Photos
HTML
1
star
30

budgetzen-android-webview

Budget Zen Android Webview "App"
Kotlin
1
star
31

loggit-android-webview

Loggit Android Webview "App"
Kotlin
1
star
32

photo-frame

A frontend-only (Vanilla JS) app used for devices that are in a "photo frame" mode.
JavaScript
1
star
33

dejal-timeout-theme-inspirational-quotes

Theme for Dejal's Time Out that shows inspirational quotes.
HTML
1
star