~> My frontend code.
Visit my live website here: https://cars-club.netlify.app
- Click the
Login as a test userbutton -
- E-mail: test@test.com
- Password: test
Combining my passion for cars I created this fullstack project with one of the main goal being that to improve my TypeScript skills. I had focused on setting up a reusable and scalable code that can be used for implementing more features. Now that it's all looking & working smoothly, my app is at a state where I can continue implementing my new ideas in the future updates seamlessly.
- Users can create a Post with an image, then submit this
multipart/form-datarequest with all the input values appended to aFormData. - I'm converting the backend's image value - a binary data - into a
srcvalue using a function that first converts it toUint8Arrayinstance, then I'm grabbing thebufferproperty value & passing it as an argument to theBlob's constructor (but passing the whole instance works as well). Finally withURL.createObjectURLI'm creating a URL from this Blob that is used as thesrcvalue.
- I'm using Multer middleware to process the
FormDatareceived from amultipart/form-datarequest with the storage optionmemoryStorage(), then usingupload.singleinstance middleware to populatereq.filewith metadata about the image. My controller only stores the binary data from thebufferproperty into my PostgreSQL as aBYTEAcolumn type. - My
refresh_tokensandpoststables both have a MANY-TO-ONE relationship with myuserstable.
Note: I'm still working on this fullstack project - it's not yet finished & my main goal is to improve my TypeScript skills. UPDATE: ✔ DONE
- Login & Register sections. ✔
- Section for cars info & specifications: Catalog. ✔
- Section for posting cars for sales (allowed by all users): Marketplace. ✔
- Posts will be connected to the OP user (original poster) & they can update or delete their post. ✔
- Users not related to a particular post will be able to comment; they will be related to their own comment & be able to update and delete their own comment. 🔃
- Clone this project.
- Navigate (
cd) into your project directory. - Run
npm installin your command line. - Run
npm run devin your command line (or modify your own scripts insidepackage.json).- The concurrently package is used to automatically "watch" for
.tsfile changes (insidesrcas specified intsconfig.json) and compile on save.- I have also added
npm run devNoOnSaveCompilecommand forts-nodewhich runs.tsfile without compiling it to.jsfirst, but it is so much slower than theconcurrentlycommand, so I don't recommend 'ts-node'.
- I have also added
- The concurrently package is used to automatically "watch" for
- Visit http://localhost:3000 in your browser.
- That's if you use Vite (V4 specifically) like I do on my frontend which runs on PORT 5173 by default.
- For the full functionality connect it with my frontend project.
- If you want to deploy the frontend part on Netlify you should copy the code included in my Frontend's netlify.toml file.
- To deploy the backend you can use alternatives to Heroku: https://render.com or https://fly.io/docs/apps/deploy (but fly.io limits to 1 free app per credit card).
- Cars Club server is deployed to render.com
- I have this
getCookieOptionsfunction you can use for most default "cookieOptions" properties or otherwise set up your own as these are not limitations.- Warning is if you deploy your app, there it might not have a
NODE_ENVenvironment variable so you must specify it to'production'(if it's not already by default; otherwise it'd use the'development'options) and also you'd need to modify that function to include adomainproperty (which is currently commented out) value of URL.
- Warning is if you deploy your app, there it might not have a
- For most of my SVG icons I've used a PNG version of icons8 and then converted that PNG into SVG using sites like https://www.pngtosvg.com.