Skip to content

Commit 4572cff

Browse files
authored
refactor: move from firebase (#211)
* wip guest-book-api * wip guest-book-api * guest-book-api modify readme and remove firebase dep * wip simple-give-away-scene and leader-board * wip validate-player-authenticity * fix validate-player-authenticity * wip * fix ignore fix versions
1 parent f30bd0a commit 4572cff

Some content is hidden

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

52 files changed

+456
-716
lines changed

.vscode/launch.json

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"sourceMapPathOverrides": {
1313
"dcl:///*": "${workspaceFolder}/*"
1414
}
15+
},
16+
{
17+
"name": "Debug Node Current File",
18+
"type": "node",
19+
"request": "launch",
20+
"program": "${file}",
21+
"skipFiles": ["<node_internals>/**"]
1522
}
1623
]
1724
}

guest-book-api/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Guest book
22

3-
Sign a guestbook. Signatures done on the guestbook are stored in a Firebase server. The code for the server is included in the `/server` folder of this repo. It also implements a few security checks to ensure that the requests that arrive to the server are legitimate.
3+
Sign a guestbook. Signatures done on the guestbook are stored in a SQLite file. The code for the server is included in the `/server` folder of this repo. It also implements a few security checks to ensure that the requests that arrive to the server are legitimate.
44

55
![](screenshot.png)
66

@@ -9,7 +9,6 @@ Check out the [related tutorial](https://decentraland.org/blog/tutorials/servers
99
This scene shows you:
1010

1111
- How to send HTTP requests to an API to store data in a permanent place, so others can then retrieve changes
12-
- How to set up a server on Firebase that uses the Firestore database
1312
- How to display a custom UI
1413
- How to parse a JSON response from an API call
1514
- How to parse a string so that it fits a maximum line length and maximum number of lines
@@ -36,10 +35,6 @@ Alternatively, you can use the command line. Inside `scene` directory run:
3635
npm run start
3736
```
3837

39-
**Setting up the server**
40-
41-
The scene is set up to make use of an existing server. To launch your own server, we recommend you deploy what's in the `server` folder to your own Firebase account, following the steps in [this tutorial](https://decentraland.org/blog/tutorials/servers-part-2/).
42-
4338
**Scene Usage**
4439

4540
Click on the guestbook to open the UI and fetch all the signatures on the book. You can flip through the pages by clicking the arrows on the sides. If you click the sign button, your user ID will be fetched and added to the list of signatures. If you run this on preview, you will be using the randomly generated `guest` UI used by preview.

guest-book-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"upgrade-sdk": "npm install --save-dev @dcl/sdk@latest",
1414
"upgrade-sdk:next": "npm install --save-dev @dcl/sdk@next"
1515
}
16-
}
16+
}

guest-book-api/server/.env

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Localhost test
2+
PORT=3008
3+
BASE_URL=
4+
5+
# PORT=3008
6+
# BASE_URL=/guest-book-api

guest-book-api/server/.firebaserc

-5
This file was deleted.

guest-book-api/server/.gitignore

+7-64
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,11 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
firebase-debug.log*
8-
firebase-debug.*.log*
1+
# Compiled JavaScript files
2+
lib/**/*.js
3+
lib/**/*.js.map
94

10-
# Firebase cache
11-
.firebase/
5+
# TypeScript v1 declaration files
6+
typings/
127

13-
# Firebase config
14-
15-
# Uncomment this if you'd like others to create their own Firebase project.
16-
# For a team working on the same Firebase project(s), it is recommended to leave
17-
# it commented so all members can deploy to the same project(s) in .firebaserc.
18-
# .firebaserc
19-
20-
# Runtime data
21-
pids
22-
*.pid
23-
*.seed
24-
*.pid.lock
25-
26-
# Directory for instrumented libs generated by jscoverage/JSCover
27-
lib-cov
28-
29-
# Coverage directory used by tools like istanbul
30-
coverage
31-
32-
# nyc test coverage
33-
.nyc_output
34-
35-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36-
.grunt
37-
38-
# Bower dependency directory (https://bower.io/)
39-
bower_components
40-
41-
# node-waf configuration
42-
.lock-wscript
43-
44-
# Compiled binary addons (http://nodejs.org/api/addons.html)
45-
build/Release
46-
47-
# Dependency directories
8+
# Node.js dependency directory
489
node_modules/
4910

50-
# Optional npm cache directory
51-
.npm
52-
53-
# Optional eslint cache
54-
.eslintcache
55-
56-
# Optional REPL history
57-
.node_repl_history
58-
59-
# Output of 'npm pack'
60-
*.tgz
61-
62-
# Yarn Integrity file
63-
.yarn-integrity
64-
65-
# dotenv environment variables file
66-
.env
67-
68-
functions/permission.json
11+
database.db

guest-book-api/server/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Running the server locally
2+
1. Run `npm i` in this folder
3+
2. Build it with `npm run build`
4+
3. Run the server with `npm run serve`

guest-book-api/server/firebase.json

-17
This file was deleted.

guest-book-api/server/functions/.gitignore

-9
This file was deleted.

guest-book-api/server/functions/src/index.ts

-108
This file was deleted.

leader-board/server/functions/package.json guest-book-api/server/package.json

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@
33
"scripts": {
44
"build": "tsc",
55
"build:watch": "tsc --watch",
6-
"serve": "npm run build && firebase emulators:start --only functions",
7-
"shell": "npm run build && firebase functions:shell",
8-
"start": "npm run shell",
9-
"deploy": "firebase deploy --only functions",
10-
"logs": "firebase functions:log"
6+
"start": "npm run build && node dist/index.js",
7+
"serve": "node dist/index.js"
118
},
129
"engines": {
1310
"node": "18"
1411
},
15-
"main": "lib/index.js",
12+
"main": "dist/index.js",
1613
"dependencies": {
14+
"@types/sqlite3": "^3.1.11",
1715
"cors": "latest",
1816
"decentraland-crypto-middleware": "latest",
17+
"dotenv": "^16.4.5",
1918
"express": "latest",
20-
"firebase-admin": "latest",
21-
"firebase-functions": "latest"
19+
"sqlite": "^5.1.1",
20+
"sqlite3": "^5.1.7"
2221
},
2322
"devDependencies": {
2423
"@types/koa": "latest",
2524
"@types/passport-strategy": "latest",
2625
"@well-known-components/interfaces": "latest",
27-
"firebase-functions-test": "latest",
2826
"typescript": "latest"
2927
},
3028
"private": true

0 commit comments

Comments
 (0)