Skip to content

Commit

Permalink
backend changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirat committed Oct 15, 2023
1 parent ce15e92 commit 2a5029d
Show file tree
Hide file tree
Showing 13 changed files with 1,450 additions and 13 deletions.
6 changes: 6 additions & 0 deletions backend/native/backpack-api/src/db/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ const transformUser = (
*/
export const createUser = async (
username: string,
firstName: string,
lastName: string,
blockchainPublicKeys: Array<{ blockchain: Blockchain; publicKey: string }>,
waitlistId?: string | null,
referrerId?: string
Expand All @@ -324,11 +326,15 @@ export const createUser = async (
],
});

// zeus - automatically generated client for graphql
//
const response = await chain("mutation")({
insert_auth_users_one: [
{
object: {
username: username,
firstname: firstName,
lastname: lastName,
public_keys: {
data: blockchainPublicKeys.map((b) => ({
blockchain: b.blockchain,
Expand Down
7 changes: 6 additions & 1 deletion backend/native/backpack-api/src/routes/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ router.get("/jwt/xnft", extractUserId, async (req, res) => {
* Create a new user.
*/
router.post("/", async (req, res) => {
const { username, waitlistId, blockchainPublicKeys } =
console.log("hi there");
const { username, waitlistId, blockchainPublicKeys, firstName, lastName } =
CreateUserWithPublicKeys.parse(req.body);

console.log(firstName);
console.log(lastName);
// Validate all the signatures
for (const blockchainPublicKey of blockchainPublicKeys) {
const signedMessage = getCreateMessage(blockchainPublicKey.publicKey);
Expand Down Expand Up @@ -182,6 +185,8 @@ router.post("/", async (req, res) => {

const user = await createUser(
username,
firstName,
lastName,
blockchainPublicKeys.map((b) => ({
...b,
// Cast blockchain to correct type
Expand Down
2 changes: 2 additions & 0 deletions backend/native/backpack-api/src/validation/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const BaseCreateUser = z.object({
/^[a-z0-9_]{3,15}$/,
"should be between 3-15 characters and can only contain numbers, letters, and underscores."
),
firstName: z.string(),
lastName: z.string(),
inviteCode: z
.string()
.regex(
Expand Down
Loading

0 comments on commit 2a5029d

Please sign in to comment.