I added an API in server.js
that uses the multer
package to return file metadata from an upload.
- You should provide your own project, not the example URL.
- You can submit a form that includes a file upload.
- The form file input field has the
name
attribute set toupfile
. - When you submit a file, you receive the file
name
,type
, andsize
in bytes within the JSON response.
- Add log middleware to help with troubleshooting.
- Create MongoDB schema and init
Url
model. - POST -
/api/shorturl
- Check if request URL is valid.
- If new, add
original_url
to database.- Increment the max
short_url
and assign to neworiginal_url
.
- Increment the max
- Return
original_url
andshort_url
.
- GET -
/api/shorturl/:urlnum
- Lookup
original_url
usingshort_url
. - Redirect to
original_url
.
- Lookup