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