diff --git a/.gitignore b/.gitignore index 3654166..424b2f0 100644 --- a/.gitignore +++ b/.gitignore @@ -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* diff --git a/.eslintrc.json b/api/.eslintrc.json similarity index 100% rename from .eslintrc.json rename to api/.eslintrc.json diff --git a/.prettierignore b/api/.prettierignore similarity index 100% rename from .prettierignore rename to api/.prettierignore diff --git a/.prettierrc b/api/.prettierrc similarity index 100% rename from .prettierrc rename to api/.prettierrc diff --git a/README.md b/api/README.md similarity index 100% rename from README.md rename to api/README.md diff --git a/package-lock.json b/api/package-lock.json similarity index 100% rename from package-lock.json rename to api/package-lock.json diff --git a/package.json b/api/package.json similarity index 100% rename from package.json rename to api/package.json diff --git a/src/constants/issues.ts b/api/src/constants/issues.ts similarity index 100% rename from src/constants/issues.ts rename to api/src/constants/issues.ts diff --git a/src/constants/projects.ts b/api/src/constants/projects.ts similarity index 100% rename from src/constants/projects.ts rename to api/src/constants/projects.ts diff --git a/src/controllers/users.ts b/api/src/controllers/authentication.ts similarity index 95% rename from src/controllers/users.ts rename to api/src/controllers/authentication.ts index c4f9298..005afaf 100644 --- a/src/controllers/users.ts +++ b/api/src/controllers/authentication.ts @@ -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); diff --git a/src/controllers/issues.ts b/api/src/controllers/issues.ts similarity index 100% rename from src/controllers/issues.ts rename to api/src/controllers/issues.ts diff --git a/src/controllers/projects.ts b/api/src/controllers/projects.ts similarity index 100% rename from src/controllers/projects.ts rename to api/src/controllers/projects.ts diff --git a/src/database/connection.ts b/api/src/database/connection.ts similarity index 100% rename from src/database/connection.ts rename to api/src/database/connection.ts diff --git a/src/database/seeds/development/comment.ts b/api/src/database/seeds/development/comment.ts similarity index 100% rename from src/database/seeds/development/comment.ts rename to api/src/database/seeds/development/comment.ts diff --git a/src/database/seeds/development/index.ts b/api/src/database/seeds/development/index.ts similarity index 100% rename from src/database/seeds/development/index.ts rename to api/src/database/seeds/development/index.ts diff --git a/src/database/seeds/development/issue.ts b/api/src/database/seeds/development/issue.ts similarity index 100% rename from src/database/seeds/development/issue.ts rename to api/src/database/seeds/development/issue.ts diff --git a/src/database/seeds/development/project.ts b/api/src/database/seeds/development/project.ts similarity index 100% rename from src/database/seeds/development/project.ts rename to api/src/database/seeds/development/project.ts diff --git a/src/database/seeds/development/user.ts b/api/src/database/seeds/development/user.ts similarity index 100% rename from src/database/seeds/development/user.ts rename to api/src/database/seeds/development/user.ts diff --git a/src/database/seeds/guestUser.ts b/api/src/database/seeds/guestUser.ts similarity index 95% rename from src/database/seeds/guestUser.ts rename to api/src/database/seeds/guestUser.ts index 91b8698..b1a9eca 100644 --- a/src/database/seeds/guestUser.ts +++ b/api/src/database/seeds/guestUser.ts @@ -90,17 +90,17 @@ const seedIssues = (project: Project): Promise => { return Promise.all(issues); }; -const seedComments = (issue: Issue): Promise => +const seedComments = (issue: Issue, user: User): Promise => 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 => { 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; diff --git a/src/entities/Comment.ts b/api/src/entities/Comment.ts similarity index 100% rename from src/entities/Comment.ts rename to api/src/entities/Comment.ts diff --git a/src/entities/Issue.ts b/api/src/entities/Issue.ts similarity index 91% rename from src/entities/Issue.ts rename to api/src/entities/Issue.ts index a42e05b..f537f35 100644 --- a/src/entities/Issue.ts +++ b/api/src/entities/Issue.ts @@ -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; diff --git a/src/entities/Project.ts b/api/src/entities/Project.ts similarity index 100% rename from src/entities/Project.ts rename to api/src/entities/Project.ts diff --git a/src/entities/User.ts b/api/src/entities/User.ts similarity index 100% rename from src/entities/User.ts rename to api/src/entities/User.ts diff --git a/src/entities/index.ts b/api/src/entities/index.ts similarity index 100% rename from src/entities/index.ts rename to api/src/entities/index.ts diff --git a/src/errors/asyncCatch.ts b/api/src/errors/asyncCatch.ts similarity index 100% rename from src/errors/asyncCatch.ts rename to api/src/errors/asyncCatch.ts diff --git a/src/errors/customErrors.ts b/api/src/errors/customErrors.ts similarity index 100% rename from src/errors/customErrors.ts rename to api/src/errors/customErrors.ts diff --git a/src/errors/errorHandler.ts b/api/src/errors/errorHandler.ts similarity index 100% rename from src/errors/errorHandler.ts rename to api/src/errors/errorHandler.ts diff --git a/src/errors/index.ts b/api/src/errors/index.ts similarity index 100% rename from src/errors/index.ts rename to api/src/errors/index.ts diff --git a/src/index.ts b/api/src/index.ts similarity index 92% rename from src/index.ts rename to api/src/index.ts index ccbbd09..e4a57eb 100644 --- a/src/index.ts +++ b/api/src/index.ts @@ -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); diff --git a/src/middleware/authentication.ts b/api/src/middleware/authentication.ts similarity index 100% rename from src/middleware/authentication.ts rename to api/src/middleware/authentication.ts diff --git a/src/types/env.d.ts b/api/src/types/env.d.ts similarity index 100% rename from src/types/env.d.ts rename to api/src/types/env.d.ts diff --git a/src/types/express.d.ts b/api/src/types/express.d.ts similarity index 100% rename from src/types/express.d.ts rename to api/src/types/express.d.ts diff --git a/src/utils/authToken.ts b/api/src/utils/authToken.ts similarity index 100% rename from src/utils/authToken.ts rename to api/src/utils/authToken.ts diff --git a/src/utils/typeorm.ts b/api/src/utils/typeorm.ts similarity index 87% rename from src/utils/typeorm.ts rename to api/src/utils/typeorm.ts index 5e459fb..0da9d5b 100644 --- a/src/utils/typeorm.ts +++ b/api/src/utils/typeorm.ts @@ -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 ( Constructor: T, diff --git a/src/utils/validation.ts b/api/src/utils/validation.ts similarity index 100% rename from src/utils/validation.ts rename to api/src/utils/validation.ts diff --git a/tsconfig.json b/api/tsconfig.json similarity index 100% rename from tsconfig.json rename to api/tsconfig.json