Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit 61be87b

Browse files
committed
initial commit
0 parents  commit 61be87b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+11502
-0
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Dockerfile
2+
.dockerignore
3+
node_modules
4+
npm-debug.log
5+
README.md
6+
dist
7+
.next
8+
.git

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
APPWRITE_FUNCTION_API_KEY=
2+
# IMPORTANT If you're running the website inside docker and your Appwrite instance runs on localhost host,
3+
# use host.docker.internal instead of localhost
4+
APPWRITE_HOST=http://appwrite/v1

.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ["eslint-config-next", "eslint:recommended"],
3+
"plugins": ["react"],
4+
"rules": {
5+
"quotes": ["warn", "double", { "allowTemplateLiterals": true }],
6+
"react-hooks/exhaustive-deps": ["off"],
7+
"import/no-anonymous-default-export": ["off"],
8+
"no-unused-vars": ["warn"],
9+
"react/no-unescaped-entities": ["off"]
10+
}
11+
}

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
.env

.setup/data/collections.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
export default [
2+
{
3+
$id: "shares",
4+
$read: [],
5+
$write: [],
6+
name: "Shares",
7+
enabled: true,
8+
permission: "document",
9+
attributes: [
10+
{
11+
key: "securityID",
12+
type: "string",
13+
status: "available",
14+
required: false,
15+
array: false,
16+
size: 255,
17+
default: null,
18+
},
19+
{
20+
key: "createdAt",
21+
type: "integer",
22+
status: "available",
23+
required: true,
24+
array: false,
25+
min: 0,
26+
max: 9007199254740991,
27+
default: null,
28+
},
29+
{
30+
key: "expiresAt",
31+
type: "integer",
32+
status: "available",
33+
required: true,
34+
array: false,
35+
min: 0,
36+
max: 9007199254740991,
37+
default: null,
38+
},
39+
{
40+
key: "visitorCount",
41+
type: "integer",
42+
status: "available",
43+
required: false,
44+
array: false,
45+
min: 0,
46+
max: 9007199254740991,
47+
default: 0,
48+
},
49+
{
50+
key: "enabled",
51+
type: "boolean",
52+
status: "available",
53+
required: false,
54+
array: false,
55+
default: false,
56+
},
57+
],
58+
indexes: [],
59+
},
60+
{
61+
$id: "shareSecurity",
62+
$read: [],
63+
$write: [],
64+
name: "ShareSecurity",
65+
enabled: true,
66+
permission: "document",
67+
attributes: [
68+
{
69+
key: "password",
70+
type: "string",
71+
status: "available",
72+
required: false,
73+
array: false,
74+
size: 128,
75+
default: null,
76+
},
77+
{
78+
key: "maxVisitors",
79+
type: "integer",
80+
status: "available",
81+
required: false,
82+
array: false,
83+
min: 0,
84+
max: 9007199254740991,
85+
default: null,
86+
},
87+
],
88+
indexes: [],
89+
},
90+
];

.setup/data/functions.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export default () => {
2+
const host = process.env["APPWRITE_HOST"].replace(
3+
"localhost",
4+
"host.docker.internal"
5+
);
6+
return [
7+
{
8+
$id: "createShare",
9+
execute: ["role:all"],
10+
name: "Create Share",
11+
runtime: "node-16.0",
12+
vars: {
13+
APPWRITE_FUNCTION_ENDPOINT: host,
14+
APPWRITE_FUNCTION_API_KEY: process.env["APPWRITE_FUNCTION_API_KEY"],
15+
},
16+
events: [],
17+
schedule: "",
18+
timeout: 15,
19+
},
20+
{
21+
$id: "finishShare",
22+
execute: ["role:all"],
23+
name: "Finish Share",
24+
runtime: "node-16.0",
25+
deployment: "625db8ded97874b96590",
26+
vars: {
27+
APPWRITE_FUNCTION_ENDPOINT: host,
28+
APPWRITE_FUNCTION_API_KEY: process.env["APPWRITE_FUNCTION_API_KEY"],
29+
},
30+
events: [],
31+
schedule: "",
32+
timeout: 15,
33+
},
34+
{
35+
$id: "cleanShares",
36+
name: "Clean Shares",
37+
runtime: "node-16.0",
38+
path: "functions/cleanShares",
39+
entrypoint: "src/index.js",
40+
execute: ["role:all"],
41+
events: [],
42+
schedule: "30,59 * * * *",
43+
timeout: 60,
44+
},
45+
];
46+
};

.setup/index.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import authService from "./services/auth.service";
2+
import setupService from "./services/setup.service";
3+
import rl from "readline-sync";
4+
5+
(async () => {
6+
console.info("\nWelcome to the Pingvin Share Appwrite setup 👋");
7+
console.info(
8+
"Please follow the questions and be sure that you ENTER THE CORRECT informations. Because the error handling isn't good.\n"
9+
);
10+
try {
11+
process.env["APPWRITE_HOST"] = rl.question(
12+
"Appwrite host (http://localhost/v1): ",
13+
{
14+
defaultInput: "http://localhost/v1",
15+
}
16+
);
17+
console.info("Authenticate...");
18+
process.env["APPWRITE_USER_TOKEN"] = await authService.getToken();
19+
20+
console.info("Creating project...");
21+
await setupService.createProject();
22+
23+
console.info("Generating API key for setup...");
24+
process.env["APPWRITE_API_KEY"] = await authService.generateApiKey();
25+
26+
console.info("Generating API key for functions...");
27+
process.env["APPWRITE_FUNCTION_API_KEY"] =
28+
await setupService.generateFunctionsApiKey();
29+
30+
console.info("Creating collections...");
31+
await setupService.createCollections();
32+
33+
console.info("Creating functions...");
34+
await setupService.createFunctions();
35+
36+
console.info("Creating function deployments...");
37+
await setupService.createFunctionDeployments();
38+
39+
console.info("Adding frontend url...");
40+
await setupService.addPlatform(
41+
rl.question("Frontend host of Pingvin Share (localhost): ", {
42+
defaultInput: "localhost",
43+
})
44+
);
45+
} catch (e) {
46+
console.error(e);
47+
console.error("\n\n ❌ Error: " + e.message);
48+
console.info(
49+
"\nSorry, an error occured while the setup. The full logs can be found above."
50+
);
51+
return;
52+
}
53+
console.info("\n✅ Done");
54+
})();
55+
export {};

0 commit comments

Comments
 (0)