Skip to content

Commit

Permalink
remove more return awaits in non ts/ paths (#1608)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolopinto authored Aug 17, 2023
1 parent f96de79 commit 796e0a7
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class CreateEventAction extends CreateEventActionBase {
return;
}

return await Promise.all(
return Promise.all(
input.activities.map(async (activity) => {
return CreateEventActivityAction.create(builder.viewer, {
eventID: builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class CreateEventActivityAction extends CreateEventActivityAction
if (!this.input.address) {
return;
}
return await CreateAddressAction.create(builder.viewer, {
return CreateAddressAction.create(builder.viewer, {
...this.input.address,
ownerID: builder,
ownerType: NodeType.EventActivity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class EditEventActivityRsvpStatusAction extends EditEventActivity
EdgeType.EventActivityToAttending,
WriteOperation.Insert,
);
return await Promise.all(
return Promise.all(
edges.map(async (edge) => {
if (edge.isBuilder(edge.id)) {
throw new Error("edge should not be a builder");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class CreateGuestGroupAction extends CreateGuestGroupActionBase {
(activity) => activity.inviteAllGuests,
);

return await Promise.all(
return Promise.all(
activities.map((activity) =>
EventActivityAddInviteAction.create(builder.viewer, activity)
.addInviteID(builder)
Expand All @@ -57,7 +57,7 @@ export default class CreateGuestGroupAction extends CreateGuestGroupActionBase {
return;
}

return await Promise.all(
return Promise.all(
input.guests.map(async (guest) => {
return CreateGuestAction.create(builder.viewer, {
eventID: input.eventID,
Expand Down
2 changes: 1 addition & 1 deletion examples/ent-rsvp/backend/src/graphql/resolvers/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export class EventResolver {
],
})
async event(context: RequestContext, slug: string) {
return await Event.loadFromSlug(context.getViewer(), slug);
return Event.loadFromSlug(context.getViewer(), slug);
}
}
4 changes: 2 additions & 2 deletions examples/ent-rsvp/backend/src/testutils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function createActivity(
eventID = event.id;
}

return await CreateEventActivityAction.create(event.viewer, {
return CreateEventActivityAction.create(event.viewer, {
startTime: new Date(),
location: "fun location",
name: "welcome dinner",
Expand Down Expand Up @@ -142,7 +142,7 @@ export async function createGuests(
group: GuestGroup,
idx: number,
): Promise<Guest[]> {
return await Promise.all(
return Promise.all(
inputs[idx].map(async (input) => {
return CreateGuestAction.create(group.viewer, {
...input,
Expand Down
2 changes: 1 addition & 1 deletion examples/ent-rsvp/ent-rsvp-web/src/initRelayEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function fetchQuery(operation, variables) {
process.env.NEXT_PUBLIC_RELAY_ENDPOINT,
fetchOptions,
);
return await response.json();
return response.json();
} catch (err) {
console.log("errrrrorrrrr");
console.error(err);
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/src/ent/tests/contact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Transaction } from "@snowtop/ent/action";
const loggedOutViewer = new LoggedOutExampleViewer();

async function createUser(): Promise<User> {
return await CreateUserAction.create(loggedOutViewer, {
return CreateUserAction.create(loggedOutViewer, {
firstName: "Jon",
lastName: "Snow",
emailAddress: randomEmail(),
Expand All @@ -29,7 +29,7 @@ async function create(
firstName: string,
lastName: string,
): Promise<Contact> {
return await CreateContactAction.create(new ExampleViewer(user.id), {
return CreateContactAction.create(new ExampleViewer(user.id), {
emails: [
{
emailAddress: randomEmail(),
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/src/ent/tests/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ID, query } from "@snowtop/ent";
const loggedOutViewer = new LoggedOutExampleViewer();

async function createUser() {
return await CreateUserAction.create(loggedOutViewer, {
return CreateUserAction.create(loggedOutViewer, {
firstName: "Jon",
lastName: "Snow",
emailAddress: randomEmail(),
Expand All @@ -28,7 +28,7 @@ async function create(
): Promise<Event> {
let user = await createUser();

return await CreateEventAction.create(loggedOutViewer, {
return CreateEventAction.create(loggedOutViewer, {
name: "fun event",
creatorID: user.id,
startTime: startTime,
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/ent/tests/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function create(opts: Partial<UserCreateInput>): Promise<User> {
phoneNumber: randomPhoneNumber(),
...opts,
};
return await CreateUserAction.create(loggedOutViewer, input).saveX();
return CreateUserAction.create(loggedOutViewer, input).saveX();
}

class OmniViewer extends ExampleViewer {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/ent/tests/user_full_text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function create(opts: Partial<UserCreateInput>): Promise<User> {
phoneNumber: randomPhoneNumber(),
...opts,
};
return await CreateUserAction.create(loggedOutViewer, input).saveX();
return CreateUserAction.create(loggedOutViewer, input).saveX();
}

test("baratheon", async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/ent/tests/user_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function create(opts: Partial<UserCreateInput>): Promise<User> {
password: "pa$$w0rd",
...opts,
};
return await CreateUserAction.create(loggedOutViewer, input).saveX();
return CreateUserAction.create(loggedOutViewer, input).saveX();
}

test("self contact query", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class ConfirmEditEmailAddressAction extends ConfirmEditEmailAddre
);
}
// delete the authCode
return await DeleteAuthCodeAction.create(
return DeleteAuthCodeAction.create(
builder.viewer,
authCode,
).changeset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class ConfirmEditPhoneNumberAction extends ConfirmEditPhoneNumber
);
}
// delete the authCode
return await DeleteAuthCodeAction.create(
return DeleteAuthCodeAction.create(
builder.viewer,
authCode,
).changeset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function create(opts: Partial<UserCreateInput>): Promise<User> {
phoneNumber: randomPhoneNumber(),
...opts,
};
return await CreateUserAction.create(loggedOutViewer, input).saveX();
return CreateUserAction.create(loggedOutViewer, input).saveX();
}

function getConfig(
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/src/graphql/tests/contact_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getUserConfig(
}

async function createUser(): Promise<User> {
return await CreateUserAction.create(loggedOutViewer, {
return CreateUserAction.create(loggedOutViewer, {
firstName: "Jon",
lastName: "Snow",
emailAddress: randomEmail(),
Expand All @@ -84,7 +84,7 @@ async function createContact(user?: User): Promise<Contact> {
userID: user.id,
}).saveX();
// reload
return await Contact.loadX(contact.viewer, contact.id);
return Contact.loadX(contact.viewer, contact.id);
}

test("query contact", async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/graphql/tests/event_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function createEvent(options: Partial<EventCreateInput>): Promise<Event> {
const user = await createUser();

let vc = new ExampleViewer(user.id);
return await CreateEventAction.create(vc, {
return CreateEventAction.create(vc, {
name: "event",
creatorID: user.id,
startTime: new Date(),
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/graphql/tests/user_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getUserRootConfig(

const loggedOutViewer = new LoggedOutExampleViewer();
async function createUser(input?: Partial<UserCreateInput>): Promise<User> {
return await CreateUserAction.create(loggedOutViewer, {
return CreateUserAction.create(loggedOutViewer, {
firstName: "first",
lastName: "last",
emailAddress: randomEmail(),
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/graphql/tests/user_auth_jwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getUserRootConfig(

const loggedOutViewer = new LoggedOutExampleViewer();
async function createUser(input?: Partial<UserCreateInput>): Promise<User> {
return await CreateUserAction.create(loggedOutViewer, {
return CreateUserAction.create(loggedOutViewer, {
firstName: "first",
lastName: "last",
emailAddress: randomEmail(),
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/graphql/tests/user_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function create(opts: Partial<UserCreateInput>): Promise<User> {
password: "pa$$w0rd",
...opts,
};
return await CreateUserAction.create(loggedOutViewer, input).saveX();
return CreateUserAction.create(loggedOutViewer, input).saveX();
}

function getNodeConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class TodosResolver {
ChangeTodoStatusAction.create(vc, todo, { completed: completed }),
),
);
return await bulk.saveX();
return bulk.saveX();
}

@gqlMutation({
Expand Down Expand Up @@ -72,6 +72,6 @@ export class TodosResolver {
AccountBuilder,
...completedTodos.map((todo) => DeleteTodoAction.create(vc, todo)),
);
return await bulk.saveX();
return bulk.saveX();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TodoResolver {
})
async openTodosPlural(id: ID): Promise<Todo[]> {
const viewer = new IDViewer(id);
return await Todo.loadCustom(
return Todo.loadCustom(
viewer,
query.And(query.Eq("assignee_id", id), query.Eq("completed", false)),
);
Expand Down
4 changes: 2 additions & 2 deletions ts/packages/ent-graphql-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export async function expectQueryFromRoot(
config: queryRootConfig,
...options: Option[] // TODO queries? expected values
): Promise<supertest.SuperTest<supertest.Test>> {
return await expectFromRoot(
return expectFromRoot(
{
...config,
queryPrefix: "query",
Expand Down Expand Up @@ -375,7 +375,7 @@ export async function expectMutation(
};
}

return await expectFromRoot(
return expectFromRoot(
{
...config,
args: args,
Expand Down
6 changes: 3 additions & 3 deletions ts/packages/ent-passport/src/passport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ let viewerType = new GraphQLObjectType({
async resolve(_source, args, context) {
const v = context.getViewer() as IDViewer;

return await v.viewer();
return v.viewer();
},
},
},
Expand Down Expand Up @@ -196,7 +196,7 @@ const authUserSessionType: GraphQLFieldConfig<
},
type: new GraphQLNonNull(viewerType),
async resolve(_source, args, context) {
return await useAndVerifyAuth(
return useAndVerifyAuth(
context,
async () => {
const row = await loadRow({
Expand Down Expand Up @@ -263,7 +263,7 @@ interface User {
}

async function createUser(opts?: Partial<User>) {
return await createRowForTest(
return createRowForTest(
{
tableName: "users",
fields: {
Expand Down
12 changes: 4 additions & 8 deletions ts/packages/ent-passport/src/passport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PassportAuthHandler implements AuthHandler {
return null;
}
let userr = await user;
return await toViewer(context, userr, this.options?.userToViewer);
return toViewer(context, userr, this.options?.userToViewer);
}

static testInitSessionBasedFunction(
Expand Down Expand Up @@ -111,7 +111,7 @@ async function toViewer(
return obj;
}
if (userToViewer) {
return await userToViewer(context, obj);
return userToViewer(context, obj);
}

throw new Error("cannot convert to Viewer");
Expand Down Expand Up @@ -322,15 +322,11 @@ export async function useAndVerifyAuth(
if (!viewerMaybe) {
return null;
}
return await toViewer(
context,
viewerMaybe,
defaultReqToViewer(loadOptions),
);
return toViewer(context, viewerMaybe, defaultReqToViewer(loadOptions));
},
});

return await useAndAuth(context, strategy, options);
return useAndAuth(context, strategy, options);
}

interface JWTOptions {
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/ent-password/src/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Password extends BaseField implements Field {
val = this.stringType.format(val);

let salt = await bcrypt.genSalt(this._cost);
return await bcrypt.hash(val, salt);
return bcrypt.hash(val, salt);
}

valid(val: any): boolean {
Expand Down

0 comments on commit 796e0a7

Please sign in to comment.