Feat: resolve dependencies & support Render free tier #68

Open
Amia33 wants to merge 4 commits from Amia33/master into master
4 changed files with 905 additions and 797 deletions

View File

@ -283,6 +283,41 @@ LOG_LEVEL=debug
# GA_ID=G-XXXX
```
### Deploy to Render & MongoDB Atlas
Note 1: Visa/Mastercard credit card needed to use two free tier services.
Note 2: Render free tier has a timeout of 15 min. Please use some monitoring program to keep it alive.
1. Register and create a MongoDB Atlas M0 (Free tier) Database
Choose these zones to minimize latency (the left column):
| MongoDB Atlas Location | Render Location |
| :----: | :----: |
| AWS: us-east-1 / Azure: eastus2 | Virginia, USA |
| AWS: us-west-2 | Oregon, USA |
| AWS: ap-southeast-1 / GCP: asia-southeast1 | Singapore |
| AWS: eu-central-1 | Frankfurt, Germany |
After creating the database, you will be redirected to security instruction page.
Please choose to allow all ips. And take a note of created user/pass.
After instruction process, go to Connect--Drivers, copy the connection string and replace pass with yours.
2. Register and create the Render Service
Choose New--"Web service"
Source code: Choose "Public Git Repository", and paste this repo's url `https://github.com/journey-ad/Moe-Counter`, then click Connect
Choose your own name
Language: Choose Node
Branch: default (Master)
Region: Choose the according location on the right column of the table above
Instance type: Choose Free
Environments: Just copy your configuration set before, and just paste into it. It will automatically parse the values.
Finally click Deploy.
(Optional) set your own custom domain. (Don't forget to change environment value as well)
(Optional) set free monitoring using any monitor system. (Most services offer free monitoring per 5 minutes, which is enough.)
## Credits
* [Glitch](https://glitch.com/)

View File

@ -13,11 +13,7 @@ const schema = new mongoose.Schema(
// the default mongodb url (local server)
const mongodbURL = process.env.DB_URL || "mongodb://127.0.0.1:27017";
mongoose.connect(mongodbURL, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
});
mongoose.connect(mongodbURL);
const Count = mongoose.connection.model("Count", schema);

View File

@ -11,17 +11,14 @@
"author": "journey-ad",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^8.2.0",
"compression": "^1.7.4",
"better-sqlite3": "^11.5.0",
"compression": "^1.7.5",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"image-size": "^0.8.3",
"mime-types": "^2.1.27",
"mongoose": "^5.9.28",
"pug": "^3.0.0",
"express": "^4.21.1",
"image-size": "^1.1.1",
"mime-types": "^2.1.35",
"mongoose": "^8.8.2",
"pug": "^3.0.3",
"zod": "^3.23.8"
},
"engines": {
"node": "16.x"
}
}

1644
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff