Skip to content

Commit c690c4c

Browse files
committed
Initial commit
0 parents  commit c690c4c

12 files changed

+3826
-0
lines changed

.env.schema

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
AWS_REGION=
2+
S3_BUCKET=
3+
WEBSOCKET_URL=
4+
LOCAL_DIR=

.eslintrc.cjs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
env: { node: true },
3+
parser: "@typescript-eslint/parser",
4+
parserOptions: {
5+
ecmaVersion: "latest",
6+
},
7+
plugins: ["@typescript-eslint"],
8+
extends: [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:prettier/recommended",
12+
],
13+
rules: {
14+
"@typescript-eslint/ban-ts-comment": "off",
15+
"@typescript-eslint/explicit-function-return-type": "off",
16+
"@typescript-eslint/explicit-module-boundary-types": "off",
17+
"@typescript-eslint/explicit-member-accessibility": "off",
18+
"@typescript-eslint/no-explicit-any": "off",
19+
20+
"no-unreachable": "off",
21+
"require-await": "error",
22+
},
23+
};

.github/workflows/deploy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Install pnpm
15+
uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
- name: Use Node.js 20
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
- name: Install, test, deploy
23+
run: |
24+
pnpm install --frozen-lockfile
25+
sh deploy.sh
26+
env:
27+
CAPROVER_PASSWORD: ${{ secrets.CAPROVER_PASSWORD }}
28+
CAPROVER_MACHINE_01: ${{ secrets.CAPROVER_MACHINE_01 }}
29+
CAPROVER_MACHINE_02: ${{ secrets.CAPROVER_MACHINE_02 }}
30+
CI: true

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
.tsimp
3+
/node_modules

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:20-alpine AS base
2+
3+
ENV PNPM_HOME="/pnpm"
4+
ENV PATH="$PNPM_HOME:$PATH"
5+
RUN corepack enable
6+
WORKDIR /app
7+
# Building presumably already happened
8+
COPY . .
9+
10+
RUN pnpm install --frozen-lockfile
11+
12+
ENV NODE_ENV production
13+
ENV PORT 80
14+
EXPOSE 80
15+
CMD [ "pnpm", "start" ]

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# s3-smart-sync
2+
3+
4+
# Dev notes
5+
6+
`tsimp` fails without providing an error message, `tsx` works. 🤷‍♀️
7+
8+
```
9+
> tsimp .
10+
11+
 ELIFECYCLE  Command failed with exit code 13.
12+
```

deploy.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e
3+
4+
export CAPROVER_APP=s3-smart-sync
5+
export CAPROVER_TAR_FILE=./caprover_deployment.tar
6+
7+
echo "Creating archive out of repo and build artifacts..."
8+
tar -cf ./caprover_deployment.tar --exclude=node_modules/* .
9+
10+
echo "Deploying to machine 01..."
11+
export CAPROVER_URL=$CAPROVER_MACHINE_01
12+
npx caprover deploy > /dev/null
13+
14+
echo "Deploying to machine 02..."
15+
export CAPROVER_URL=$CAPROVER_MACHINE_02
16+
npx caprover deploy > /dev/null
17+
18+
rm caprover_deployment.tar

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "s3-smart-sync",
3+
"version": "1.0.0",
4+
"main": "./src/server.ts",
5+
"type": "module",
6+
"license": "MIT",
7+
"scripts": {
8+
"lint": "eslint .",
9+
"start": "tsimp .",
10+
"start:client": "tsimp ./src/client.ts"
11+
},
12+
"devDependencies": {
13+
"@types/aws-lambda": "^8.10.145",
14+
"@types/body-parser": "^1.19.5",
15+
"@types/express": "^5.0.0",
16+
"@types/node": "^20.15.0",
17+
"@types/ws": "^8.5.12",
18+
"@typescript-eslint/eslint-plugin": "7.14.1",
19+
"@typescript-eslint/parser": "7.14.1",
20+
"eslint": "8.57.0",
21+
"eslint-config-prettier": "9.1.0",
22+
"eslint-plugin-prettier": "5.1.3",
23+
"prettier": "3.3.2",
24+
"tsimp": "^2.0.11",
25+
"typescript": "^5.6.2"
26+
},
27+
"dependencies": {
28+
"@aws-sdk/client-s3": "^3.665.0",
29+
"@aws-sdk/client-sns": "^3.665.0",
30+
"body-parser": "^1.20.3",
31+
"chokidar": "^4.0.1",
32+
"dotenv": "^16.4.5",
33+
"express": "^4.21.0",
34+
"ws": "^8.18.0"
35+
}
36+
}

0 commit comments

Comments
 (0)