Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lujia-Cheng committed Jan 31, 2024
0 parents commit ed0b237
Show file tree
Hide file tree
Showing 34 changed files with 21,107 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/backend-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy Backend

on:
push:
workflow_dispatch:

jobs:
test: # just make sure the node server can be run
defaults:
run:
working-directory: ./backend

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install

- name: Run tests
run: npm start

deploy:
needs: test

defaults:
run:
working-directory: ./backend

permissions:
pages: write
id-token: write

runs-on: ubuntu-latest
steps:
- name: Checkout Glitch.com repository
uses: actions/checkout@v4
with:
repository: ${{ secrets.BACKEND_GIT_URL }}
path: glitch-repo

- name: Initialize git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Fetch Changes from GitHub Repository
uses: actions/checkout@v4
with:
path: github-repo

- name: Copy files from GitHub Repository to Glitch.com Repository
run: cp -r ${{ github.workspace }}/github-repo/* ${{ github.workspace }}/glitch-repo

- name: Commit changes
run: |
git add .
git commit -m "Github Actions: deploy to glitch.com"
- name: Deploy (git force push) to glitch.com # best way so far to deploy to glitch.com
run: git push ${{ secrets.BACKEND_GIT_URL }}
59 changes: 59 additions & 0 deletions .github/workflows/frontend-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy Frontend

on:
push:
workflow_dispatch:

jobs:
build:
defaults:
run:
working-directory: ./frontend

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache dependcies
uses: actions/cache@v4
id: cache
with:
path: ./frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies if not found
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

- name: Build react to webpage
run: npm run build

- name: Upload built files as artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./frontend/build

deploy:
needs: build

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.env
**/node_modules
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Luke Cheng

> my zero budget personal webpage
## root

## Frontend

> React
## Backend

> Express
## Database

> MongoDB
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.glitchdotcom.json
.node-gyp
node_modules
1 change: 1 addition & 0 deletions backend/.glitch-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"illustration.svg","date":"2021-04-12T02:54:29.568Z","url":"https://cdn.glitch.com/c62efef6-1e75-45cf-b248-afeccdda9477%2Fillustration.svg","type":"image/svg+xml","size":17429,"imageWidth":620,"imageHeight":587,"thumbnail":"https://cdn.glitch.com/c62efef6-1e75-45cf-b248-afeccdda9477%2Fthumbnails%2Fillustration.svg","thumbnailWidth":330,"thumbnailHeight":313,"uuid":"T5MUea9IPDI0uFCw"}
29 changes: 29 additions & 0 deletions backend/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The LICENSE file for any project gives credit to the creator/author of the
project, copyright information for the project, and the legal terms under
which it's being shared. In other words, this is us using an MIT license to
say "we wrote this and you can do whatever you want with it."

******************************************************************************
~glitch-hello-node
******************************************************************************
MIT License

Copyright (c) 2021, Glitch, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Hello Node (blank)

[Node.js](https://nodejs.org/en/about/) is a popular runtime that lets you run JavaScript on the server. This project uses the [Fastify](https://www.fastify.io/) framework and basic templating with [Handlebars](https://handlebarsjs.com/).

_Last updated: 14 August 2023_

## What's in this project?

`README.md`: That’s this file, where you can tell people what your cool website does and how you built it.

`public/style.css`: The styling rules for your pages and posts.

`server.js`: The main server script for your new site.

`src/`: This folder holds page templates, additional scripts.

### Working in the `src/` folder 📁

`src/pages/index.hbs`: This is the main page template for your site.

![Glitch](https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg?v=1602781328576)

## You built this with Glitch!

[Glitch](https://glitch.com) is a friendly community where millions of people come together to build web apps and websites.

- Need more help? [Check out our Help Center](https://help.glitch.com/) for answers to any common questions.
- Ready to make it official? [Become a paid Glitch member](https://glitch.com/pricing) to boost your app with private sharing, more storage and memory, domains and more.
34 changes: 34 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "lcheng-persoanl-webpage-backend",
"version": "0.1.0",
"description": "Backend of the webpage",
"main": "server.js",
"private": true,
"scripts": {
"start": "node server.js",
"test": "npm start"
},
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"bcrypt": "^5.1.1",
"faker": "^6.6.6",
"validator": "^13.11.0",
"mongoose": "^6.12.4",
"mongodb": "^5.9.2",
"jsonwebtoken": "^9.0.2",
"openai": "^4.24.1"
},
"engines": {
"node": "16.x"
},
"repository": {
"url": "https://lujia-cheng.github.io"
},
"license": "MIT",
"keywords": [
"node",
"glitch",
"express"
]
}
37 changes: 37 additions & 0 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require("path");
const express = require("express");
const cors = require("cors");
// const mongoose = require("mongoose");
// const bcrypt = require("bcrypt");
// const validator = require("validator");
// const jwt = require("jsonwebtoken");

const app = express();

// connect to DB
// const mongoDB =
// "mongodb+srv://" +
// process.env.USERNAME +
// ":" +
// process.env.PASSWORD +
// "@" +
// process.env.HOST +
// "/" +
// process.env.DATABASE;
// mongoose.connect(mongoDB);

app.use(cors());
app.use(express.json());

app.get("/", (req, res) => {
res.status(200).send("hello world!");
});

// Handle 404
app.use(function (request, response) {
response.status(404).json({ message: "Undefined API routes" });
});

const listener = app.listen(process.env.PORT || 4000, function () {
console.log("Your app is listening on port " + listener.address().port);
});
Loading

0 comments on commit ed0b237

Please sign in to comment.