Moved api into it's own folder
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,12 +1,12 @@
|
|||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
**/node_modules
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
**/.DS_Store
|
||||||
|
|
||||||
# environment config
|
# environment config
|
||||||
.env
|
**/.env
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
**/build
|
||||||
npm-debug.log*
|
**/npm-debug.log*
|
||||||
|
|||||||
0
package-lock.json → api/package-lock.json
generated
0
package-lock.json → api/package-lock.json
generated
@@ -9,7 +9,7 @@ import seedGuestUserEntities from 'database/seeds/guestUser';
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/users/guest',
|
'/authentication/guest',
|
||||||
catchErrors(async (req, res) => {
|
catchErrors(async (req, res) => {
|
||||||
const user = await createEntity(User, req.body);
|
const user = await createEntity(User, req.body);
|
||||||
await seedGuestUserEntities(user);
|
await seedGuestUserEntities(user);
|
||||||
@@ -90,17 +90,17 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
|||||||
return Promise.all(issues);
|
return Promise.all(issues);
|
||||||
};
|
};
|
||||||
|
|
||||||
const seedComments = (issue: Issue): Promise<Comment> =>
|
const seedComments = (issue: Issue, user: User): Promise<Comment> =>
|
||||||
createEntity(Comment, {
|
createEntity(Comment, {
|
||||||
body: "Be nice to each other! Don't be mean to each other!",
|
body: "Be nice to each other! Don't be mean to each other!",
|
||||||
issue,
|
issue,
|
||||||
user: issue.users[0],
|
user,
|
||||||
});
|
});
|
||||||
|
|
||||||
const seedGuestUserEntities = async (user: User): Promise<void> => {
|
const seedGuestUserEntities = async (user: User): Promise<void> => {
|
||||||
const project = await seedProject(user);
|
const project = await seedProject(user);
|
||||||
const issues = await seedIssues(project);
|
const issues = await seedIssues(project);
|
||||||
await seedComments(issues[issues.length - 1]);
|
await seedComments(issues[issues.length - 1], project.users[0]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default seedGuestUserEntities;
|
export default seedGuestUserEntities;
|
||||||
@@ -47,6 +47,12 @@ class Issue extends BaseEntity {
|
|||||||
@Column({ type: 'integer', nullable: true })
|
@Column({ type: 'integer', nullable: true })
|
||||||
estimate: number | null;
|
estimate: number | null;
|
||||||
|
|
||||||
|
@Column({ type: 'integer', nullable: true })
|
||||||
|
timeSpent: number | null;
|
||||||
|
|
||||||
|
@Column({ type: 'integer', nullable: true })
|
||||||
|
timeRemaining: number | null;
|
||||||
|
|
||||||
@CreateDateColumn({ type: 'timestamp' })
|
@CreateDateColumn({ type: 'timestamp' })
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@@ -6,6 +6,7 @@ import cors from 'cors';
|
|||||||
|
|
||||||
import createDatabaseConnection from 'database/connection';
|
import createDatabaseConnection from 'database/connection';
|
||||||
import { authenticateUser } from 'middleware/authentication';
|
import { authenticateUser } from 'middleware/authentication';
|
||||||
|
import authenticationRoutes from 'controllers/authentication';
|
||||||
import projectsRoutes from 'controllers/projects';
|
import projectsRoutes from 'controllers/projects';
|
||||||
import issuesRoutes from 'controllers/issues';
|
import issuesRoutes from 'controllers/issues';
|
||||||
import { RouteNotFoundError } from 'errors';
|
import { RouteNotFoundError } from 'errors';
|
||||||
@@ -34,6 +35,8 @@ const initializeExpress = (): void => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use('/', authenticationRoutes);
|
||||||
|
|
||||||
app.use('/', authenticateUser);
|
app.use('/', authenticateUser);
|
||||||
|
|
||||||
app.use('/', projectsRoutes);
|
app.use('/', projectsRoutes);
|
||||||
@@ -4,10 +4,10 @@ import { Project, User, Issue, Comment } from 'entities';
|
|||||||
import { EntityNotFoundError, BadUserInputError } from 'errors';
|
import { EntityNotFoundError, BadUserInputError } from 'errors';
|
||||||
import { generateErrors } from 'utils/validation';
|
import { generateErrors } from 'utils/validation';
|
||||||
|
|
||||||
export type EntityConstructor = typeof Project | typeof User | typeof Issue | typeof Comment;
|
type EntityConstructor = typeof Project | typeof User | typeof Issue | typeof Comment;
|
||||||
export type EntityInstance = Project | User | Issue | Comment;
|
type EntityInstance = Project | User | Issue | Comment;
|
||||||
|
|
||||||
export const entities: { [key: string]: EntityConstructor } = { Comment, Issue, Project, User };
|
const entities: { [key: string]: EntityConstructor } = { Comment, Issue, Project, User };
|
||||||
|
|
||||||
export const findEntityOrThrow = async <T extends EntityConstructor>(
|
export const findEntityOrThrow = async <T extends EntityConstructor>(
|
||||||
Constructor: T,
|
Constructor: T,
|
||||||
Reference in New Issue
Block a user