Milestones
Class Project Milestones!
Class Project Milestones!
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Follow the instructions in the Example Project to build a project using Node.js and Express that includes the following features:
compression
and helmet
Effectively, just follow along with the example project and submit the resulting repository. This will be the starting point for the rest of the milestones!
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Building from the previous milestone, expand upon the starter project by adding the following features:
Seed data is stored in CSV files that can be downloaded from Canvas. See Seeding from a CSV File for an example of how to read data from a CSV file when seeding the database.
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Building from the previous milestone, expand upon the starter project by adding the following features:
/api/v1/documents/{id}/upload
API path handles file uploads! We haven’t covered that in these examples, but there are some prior examples in this class to build upon.You can download this specification file by clicking the link below, and then edit the servers
section to test it using your server. You can use the Open API Editor to see a cleaner view of this JSON file.
The OpenAPI specification looks best using the light theme. You can adjust the textbook theme in the left sidebar at the bottom of the textbook page.
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Building from the previous milestone, expand upon the starter project by adding the following features:
.env
file, it should allow authentication via the /auth/bypass?token=<username>
route.https://testcas.cs.ksu.edu
server. CAS settings should be controlled via the .env
file./auth/token
route as shown in the tutorial. The token should include the user’s ID and a list of roles assigned to the user./api/v1
path./api/v1
path. See below for a matrix of roles and allowed actions.owner_user_id
foreign key is automatically set to the currently authenticated user (it should no longer be provided as part of the POST request to create a new community or metadata, nor should it be editable via PUT request.)/api/v1/users
manage_users
/api/v1/roles
manage_users
/api/v1/communities
view_communities
, manage_communities
, add_communities
]manage_communities
, add_communities
]manage_communities
]manage_communities
]/api/v1/counties
view_communities
, manage_communities
, add_communities
]/api/v1/documents
view_documents
, manage_documents
, add_documents
]manage_documents
, add_documents
] (including file uploads)manage_documents
]manage_documents
]/api/v1/metadata
view_documents
, manage_documents
, add_documents
]manage_documents
, add_documents
] (including adding and removing communities and documents to metadata)manage_documents
]manage_documents
]UPDATED FOR MILESTONE 4
You can download this specification file by clicking the link below, and then edit the servers
section to test it using your server. You can use the Open API Editor to see a cleaner view of this JSON file.
The OpenAPI specification looks best using the light theme. You can adjust the textbook theme in the left sidebar at the bottom of the textbook page.
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Follow the instructions in the Example Project to build a project using Vue.js that includes the following features:
/profile
page listing all users and roles assigned to those users (this page should load correctly for the admin
user)Effectively, just follow along with the example project and submit the resulting repository. This will be the starting point for the rest of the milestones!
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Building from the previous milestone, expand upon the starter project by adding the following features:
manage_users
role. Roles are not editable.manage_users
role.view_communities
, manage_communities
and add_communities
roles. Counties are not editable.view_communities
, manage_communities
and add_communities
roles.manage_communities
role.manage_communities
and add_communities
roles.manage_communities
role.admin
view_documents
, manage_documents
and add_documents
roles.manage_documents
role.manage_documents
and add_documents
roles.manage_documents
role.We will NOT be handling the interface for metadata in this milestone. That will be the last milestone for this project.
To make filenames clickable, you’ll need to add an additional proxy route to the client/vite.config.js
to allow users to access the uploads
folder (or wherever you are storing your uploaded files). You can continue to use the Express static file middleware to serve these files.
To simplify the file upload process, you may want to ensure that files are named with the appropriate file extensions to match their mimetypes on the server. Below is an example if you are using multer to handle file uploads - it uses nanoid to generate random filenames and mime-types to get the correct file extension to match the mimetype of the file. You can then store the filename, size, and mimetype you get from multer in your endpoint for uploading files.
// Initialize Multer
const storage = multer.diskStorage({
destination: "public/uploads",
filename: function (req, file, cb) {
cb(null, nanoid() + "." + mime.extension(file.mimetype));
},
});
const upload = multer({ storage: storage });
On the frontend, you can use the PrimeVue FileUpload component to select the file, but you should implement a Custom Upload handler.
A brief but incomplete example is given below:
<script setup>
// Import Libraries
import { ref } from 'vue'
import { api } from '@/configs/api'
import { FileUpload, Button } from 'primevue'
// Declare State
const file = ref()
// Upload function - could possibly call this after saving the document but before redirecting
const upload = function (documentid) {
// If the user has selected a file
if (file.value.hasFiles) {
// Fetch the file from the user's filesystem into the browser
fetch(file.value.files[0].objectURL)
// convert the file to a blob
.then((response) => response.blob())
.then((blob) => {
// Create a file from the blob and add it to a form data object
const fileUpload = new File([blob], file.value.files[0].name, { type: blob.type })
const form = new FormData()
form.append('file', fileUpload)
// Upload that form to the endpoint
api
.post('/api/v1/documents/' + documentid + '/upload', form, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
.then(function (response) {
// handle success
})
.catch(function (error) {
// handle error uploading file
})
})
.catch(function (error) {
// handle error reading file
})
} else {
// No file was selected
}
}
</script>
<FileUpload ref="file" mode="basic" name="file" customUpload />
<Button severity="success" @click="upload(props.id)" label="Upload" />
<template>
This set of milestones is all about building a RESTful API and interface for the Lost Kansas Communities project.
Building from the previous milestone, expand upon the starter project by adding the following features:
Metadata view
Fix bugs