
register.ts:
TypeScript
import { account, databases, users } from '../../appwrite manager/appwrite';
import { ID } from 'appwrite';
import { DB_CONFIG } from '../../used_values';
export function setupAccountRoute(app: Elysia) {
app.post(
'/create-account',
async ({ body }) => {
try {
const { email, phoneNum, password, name } = body;
// Validate input
if (!email || !phoneNum||!password || !name) {
return { error: 'Email, phoneNumber, password, and name are required' };
}
// Create a new user account in Appwrite
const newUser = await account.create(
ID.unique(), // Generate a unique user ID
email,
// phoneNum,
password,
name,
);
console.log(DB_CONFIG.userDb);
await account.createEmailPasswordSession(email, password);
const db = await databases.getDocument(
DB_CONFIG.userDb,
DB_CONFIG.userBasicDataCol,
"67a80710003c1ce258de"
);
return { success: true, message: 'Account created successfully', user: newUser };
} catch (error: any) {
return { error: error.message || 'Failed to create account' };
}
},
{
body: t.Object({
email: t.String(), // Email must be a string
phoneNum: t.String(),
password: t.String(), // Password must be a string
name: t.String(), // Name must be a string
}),
}
);
}```
TL;DR
Issue: Database not found error when trying to access a database.
Solution: Check the configuration values being used for the database and ensure they are correct. Double-check the database name and collection name being referenced in the code.Recommended threads
- Document Data is null.
I'm using flutter and I've just got everything set up, the document meta data is null but the actual query is fine. (see screenshot) The permission I have ar...
- Do I need Redis if using appwrite
Saw appwrite has built-in redis, but does this work for listdocuments, getdocument and other query etc? what does the appwrite redis covers under the hood?
- 404 for self-host
docker-compose.yml: x-logging: &x-logging logging: driver: 'json-file' options: max-file: '5' max-size: '10m' services: traefik: ima...
