removed .env. SMPT Supertokens.

This commit is contained in:
2022-09-09 00:36:36 +02:00
parent fb0ca6a3ba
commit 6d19022c64
7 changed files with 195 additions and 45 deletions

View File

@@ -6,6 +6,7 @@ import {
import supertokens from 'supertokens-node';
import ThirdPartyEmailPassword from 'supertokens-node/recipe/thirdpartyemailpassword';
import EmailPassword from 'supertokens-node/recipe/emailpassword';
import { STMPService } from 'supertokens-node/recipe/thirdpartyemailpassword/emaildelivery';
import Session from 'supertokens-node/recipe/session';
@@ -19,7 +20,23 @@ export class SupertokensService {
apiKey: config.apiKey,
},
recipeList: [
EmailPassword.init(),
EmailPassword.init({
emailDelivery: {
service: new STMPService({
smtpSettings: {
host: process.env.SMTP_HOST,
authUsername: process.env.SMTP_USERNAME,
password: process.env.SMTP_PASSWORD,
port: parseInt(process.env.SMTP_PORT),
from: {
name: process.env.SMTP_FROM_NAME,
email: process.env.SMTP_FROM_EMAIL,
},
secure: process.env.SMTP_SECURE ? true : false,
},
}),
},
}),
ThirdPartyEmailPassword.init({
providers: [
ThirdPartyEmailPassword.Google({

View File

@@ -13,6 +13,14 @@ export class CreateUserInput {
password: string;
}
export class UpdateUserInput {
email?: Nullable<string>;
password?: Nullable<string>;
time_joined?: Nullable<number>;
createdAt?: Nullable<DateTime>;
updatedAt?: Nullable<DateTime>;
}
export class User {
id: string;
email: string;
@@ -31,6 +39,8 @@ export abstract class IQuery {
export abstract class IMutation {
abstract createUser(createUserInput: CreateUserInput): User | Promise<User>;
abstract updateUser(id: string, updateUserInput: UpdateUserInput): Nullable<User> | Promise<Nullable<User>>;
abstract removeUser(id: string): Nullable<User> | Promise<Nullable<User>>;
}

View File

@@ -1,10 +1,10 @@
scalar DateTime
type User {
id: String!
id: ID!
email: String!
password: String
time_joined: Int,
time_joined: Int
createdAt: DateTime
updatedAt: DateTime
}
@@ -14,17 +14,21 @@ input CreateUserInput {
password: String!
}
# input UpdateUserInput {
# id: String!
# }
input UpdateUserInput {
email: String
password: String
time_joined: Int
createdAt: DateTime
updatedAt: DateTime
}
type Query {
users: [User]!
user(id: String!): User
user(id: ID!): User
}
type Mutation {
createUser(createUserInput: CreateUserInput!): User!
# updateUser(updateUserInput: UpdateUserInput!): User!
removeUser(id: String!): User
updateUser(id: ID!, updateUserInput: UpdateUserInput!): User
removeUser(id: ID!): User
}

View File

@@ -18,17 +18,12 @@ export class UsersService {
return this.prismaService.user.create({ data: createUserInput });
}
// findAll() {
// return `This action returns all users`;
// }
// findOne(id: string) {
// return `This action returns a #${id} user`;
// }
// update(id: string, updateUserInput: UpdateUserInput) {
// return `This action updates a #${id} user`;
// }
update(id: string, userUpdateInput: Prisma.UserUpdateInput) {
return this.prismaService.user.update({
where: { id },
data: userUpdateInput,
});
}
// remove(id: string) {
// return `This action removes a #${id} user`;