Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial server app scaffolding #3579

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ac0e232
initial server app scaffolding
halocline Oct 27, 2023
666104c
add error handling and rename sub repo
halocline Oct 27, 2023
30731f3
refactor directory structure
halocline Oct 27, 2023
232ee39
add users and posts
halocline Oct 27, 2023
6f93ca4
create logger util
halocline Oct 28, 2023
10e17ed
add create user route and add to database
halocline Oct 28, 2023
ccee2ca
add sample .env file
halocline Oct 28, 2023
1227a69
stub out auth middleware
halocline Oct 28, 2023
417e9ba
add posts routes
halocline Oct 28, 2023
a219c9e
add createdAt and updatedAt to db models
halocline Oct 29, 2023
92d1aae
switch to mongodb
halocline Dec 2, 2023
e3adcdb
modify package structure
halocline Dec 2, 2023
a6f7ed4
resolve yarn.lock merge conflicts
halocline Dec 2, 2023
e795abf
add get user and update user routes
halocline Dec 2, 2023
63827b1
add get, update, and delete post routes
halocline Dec 2, 2023
0bd4bdf
Watch for file changes and restart server
halocline Dec 2, 2023
d228b35
Added routes for managing components
halocline Dec 2, 2023
f2fa0eb
Fix update component endpoint
halocline Dec 2, 2023
ae750a1
initial design system manager app commit
halocline Dec 2, 2023
6c26d9b
Added ReverseAnchor to aries-core
halocline Dec 3, 2023
828cdb6
make aries-core controls exportable
halocline Dec 3, 2023
b8e094d
modify ReveserAnchor to forward ref from routed link
halocline Dec 3, 2023
951293f
export prop types for ReverseAnchor
halocline Dec 3, 2023
266f929
Add ComponentList, layout, page, and types for managing components in…
halocline Dec 3, 2023
331fe3f
Add detail page for components
halocline Dec 4, 2023
8489ac2
refactor components collection page
halocline Dec 5, 2023
4ffd69e
Add initial content scaffold for component detail pages
halocline Dec 5, 2023
9f4fb7a
fix issue with viewport height in main
halocline Dec 5, 2023
d02e898
progress on component detail page
halocline Dec 6, 2023
a6f3e9a
make page layout kind narrow
halocline Dec 6, 2023
bc97c53
progress on component detail page
halocline Dec 6, 2023
13cc385
progress on component detail page
halocline Dec 6, 2023
9ef758b
progress on component detail page
halocline Dec 6, 2023
e42f4c7
use server for update action
halocline Dec 8, 2023
e931c5d
clean ups
halocline Dec 8, 2023
2ccb7a3
Add updateComponent and cache revalidation
halocline Dec 9, 2023
92dc929
Refactor editable mode
halocline Dec 9, 2023
8566cac
refine collection card grid presentation
halocline Dec 10, 2023
10316e2
more refinements
halocline Dec 10, 2023
580e7da
Modifications to edit and display properties
halocline Dec 10, 2023
ab1571a
Remove console.logs
halocline Dec 10, 2023
309e30b
refactor components actions, routes, and validation rules
halocline Dec 12, 2023
92ea7be
Added routes for attaching resources to a component
halocline Dec 12, 2023
4def39e
stub out resources list
halocline Dec 13, 2023
b315101
adjust primary page layout
halocline Dec 13, 2023
d750536
home page layout tweaks
halocline Dec 13, 2023
b6c3e97
Added skip links
halocline Dec 13, 2023
b3e9f4f
prodress on resources editing
halocline Dec 16, 2023
7e168e9
progress on updating resources
halocline Dec 17, 2023
1a3495e
revalidate path on update
halocline Dec 18, 2023
42c47d6
refactor resources edit
halocline Dec 18, 2023
6ad745a
resolve type error
halocline Dec 18, 2023
927d4ce
change implementation of detail panel heading
halocline Dec 18, 2023
bffcea9
implement detail edit mode as layer
halocline Dec 18, 2023
2eaa754
isolate touched values so that only modified properties are updated i…
halocline Dec 22, 2023
df7240c
add ids to modifiedValues
halocline Dec 22, 2023
b4b87ea
progress on updating resource values
halocline Dec 23, 2023
7591075
Merge branch 'master' into server
halocline Feb 16, 2024
5cf3857
added error resources error message
halocline Feb 17, 2024
5c8d0c1
rename api directory
halocline Feb 17, 2024
3596016
fix some typescript linting errors
halocline Feb 17, 2024
e6b2d44
layout work and add pane for content containers
halocline Feb 18, 2024
939dce7
refactor component page to use Pane
halocline Feb 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add sample .env file
  • Loading branch information
halocline committed Oct 28, 2023
commit ccee2ca016ec7332d675bacc782f0a345f52f47b
7 changes: 7 additions & 0 deletions demo-api/SAMPLE.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="file:./dev.db"
Binary file modified demo-api/prisma/dev.db
Binary file not shown.
70 changes: 66 additions & 4 deletions demo-api/src/users/routes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { Router, Request, Response } from 'express';
import { body, validationResult } from 'express-validator';
import { PrismaClient } from '@prisma/client';
import { Post } from '../posts/model';
import { User } from './model';

const prisma = new PrismaClient();

const router = Router();

const userValidationRules = [
body('email').notEmpty().isEmail().withMessage('Email is required.'),
body('email').optional().trim().isEmail().withMessage('Email must be a valid email address.'),
];

const createUserValidationRules = [
body('email').notEmpty().withMessage('Email is required.'),
...userValidationRules,
];

const updateUserValidationRules = [
body('id').notEmpty().withMessage('ID is required.'),
...userValidationRules,
];

const createUser = async (req: Request, res: Response) => {
@@ -23,7 +31,7 @@ const createUser = async (req: Request, res: Response) => {
return user;
}

router.post('/', userValidationRules, async (req: Request, res: Response) => {
router.post('/', createUserValidationRules, async (req: Request, res: Response) => {
const errors = validationResult(req);

if (!errors.isEmpty()) {
@@ -39,6 +47,60 @@ router.post('/', userValidationRules, async (req: Request, res: Response) => {
});
});

router.get('/', async (req: Request, res: Response) => {
const users = await prisma.user.findMany();
res.json(users);
await prisma.$disconnect();
});

router.get('/:id', async (req: Request, res: Response) => {
const id = parseInt(req.params.id);
const user = await prisma.user.findUnique({
where: {
id: id,
},
});

if (!user) {
res.status(404).send('User not found');
} else {
res.json(user);
}

await prisma.$disconnect();
});

router.put('/:id', updateUserValidationRules, async (req: Request, res: Response) => {
const id = parseInt(req.params.id);
const user = await prisma.user.findUnique({
where: {
id: id,
},
});
const errors = validationResult(req);

if (!errors.isEmpty()) {
return res.status(422).json({ errors: errors.array() });
}

if (!user) {
res.status(404).send('User not found');
} else {
const updatedUser = await prisma.user.update({
where: {
id: id,
},
data: {
email: req.body.email || user.email,
name: req.body.name || user.name
},
});

res.json(updatedUser);
}

await prisma.$disconnect();
});

const usersRouter = router;
export default usersRouter;