After cloning your repository and running the code, I encountered a backtrace:
ConnectionNotFoundError: Connection "default" was not found.
at new ConnectionNotFoundError (/Users/lithium/develop/typescript-api-with-tdd/src/error/ConnectionNotFoundError.ts:8:9)
at ConnectionManager.get (/Users/lithium/develop/typescript-api-with-tdd/src/connection/ConnectionManager.ts:40:19)
at Object.getRepository (/Users/lithium/develop/typescript-api-with-tdd/src/index.ts:287:35)
at new UserRepository (/Users/lithium/develop/typescript-api-with-tdd/src/infra/typeorm/repositories/UserRepository.ts:14:26)
at Object.exports.makeCreateUser (/Users/lithium/develop/typescript-api-with-tdd/src/main/factories/useCases/user/CreateUserFactory.ts:5:26)
at Object.exports.makeSignUpController (/Users/lithium/develop/typescript-api-with-tdd/src/main/factories/controllers/user/SignUpControllerFactory.ts:6:31)
at Object.<anonymous> (/Users/lithium/develop/typescript-api-with-tdd/src/main/routes/SignUp.ts:5:26)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Module._compile (/Users/lithium/develop/typescript-api-with-tdd/node_modules/source-map-support/source-map-support.js:547:25)
at Module.m._compile (/private/var/folders/fx/7f3mc02s4lxbzjmzvw4cmknh0000gn/T/ts-node-dev-hook-1775948954112352.js:57:33)
[ERROR] 10:41:29 ConnectionNotFoundError: Connection "default" was not found.
The error originated from UserRepository.ts:14:26)
,
constructor() {
this.ormRepository = getRepository(User);
}
It seems that you are attempting to create a repository or manager without establishing the connection. Placing the statement
const repo = await getRepository(User);
within a function should resolve this issue!