I decided to rewrite my portfolio site [WIP]
- Create
layout.ejs
andindex.ejs
for initial page (maybe make partials/components folder in views for further seperation) - Configure routes (Make a
visitor.mjs
and anadmin.mjs
) - Convert api.mjs into a folder and create another visitor api and admin api mjs files (Maybe, unsure on how to seperate that)
- Start working on the pages the user will see (
/
,/projects
, etc) and the middleware - Start working on API and the controllers
- Configure tor website around now
- Routes/controllers/services
export const controllerFunc = (req, res) => {
databaseService.add(req.body.id, req.body.something)
}
export const apiAControllerFunc = (req, res) => {
oauthservice.auth(req.headers),
return ...
}
// Essentially, routes will contain nothing other than
router.get("/DBAddEndpoint", controllers.database.add);
// the services will do the heavily lifting. they use the database library and interface with it. controllers just passes the data required, and routers will specify the endpoint
- If i want a blog, maybe i can store images in github and add files through github's api to something like
siteimagerepo
. Probably dont use a folder in this repo/l because it will go against replit's storage. - Even better idea, store all blogs and their resources in a github repo, then fetch that and display it. i can write blogs through replit or make my own interface on the site.
- Blogs may be stored in a db as well (such as a json one with lowdb) though this makes images much harder
- Convert all images to webp before storing them, much better for websites
import { lightfetch as fetch } from 'lightfetch-node';
const TOKEN = process.env.GITHUB_TOKEN || "FAKETOKEN";
fetch("https://api.github.com/repos/EpicGamer007/images-storage/contents/README.md", {
method: "GET",
headers: {
"Authorization": `token ${TOKEN}`,
"User-Agent": "EpicGamer007"
}
}).then(res => {
console.log(res.status);
console.log(res.json());
});