more logging
This commit is contained in:
parent
ef5f0c9444
commit
46d7f45e1a
|
@ -18,12 +18,10 @@ app.use(cors({
|
||||||
// origin: "*",
|
// origin: "*",
|
||||||
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ["GET","HEAD","PUT","POST","DELETE"],
|
|
||||||
}));
|
}));
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
// res.append('Access-Control-Allow-Origin', ['*']);
|
// res.append('Access-Control-Allow-Origin', ['*']);
|
||||||
res.append('Access-Control-Allow-Methods', 'GET,HEAD,PUT,POST,DELETE');
|
res.append('Access-Control-Allow-Methods', 'GET,HEAD,PUT,POST,DELETE,OPTIONS');
|
||||||
res.append("test-header", "cool");
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
if (inProd) app.set('trust proxy', 1);
|
if (inProd) app.set('trust proxy', 1);
|
||||||
|
|
|
@ -49,12 +49,18 @@ export async function getAllLingdocsUsers(): Promise<T.LingdocsUser[]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function insertLingdocsUser(user: T.LingdocsUser): Promise<T.LingdocsUser> {
|
export async function insertLingdocsUser(user: T.LingdocsUser): Promise<T.LingdocsUser> {
|
||||||
const res = await usersDb.insert(user);
|
try {
|
||||||
const newUser = processAPIResponse(user, res);
|
const res = await usersDb.insert(user);
|
||||||
if (!newUser) {
|
const newUser = processAPIResponse(user, res);
|
||||||
|
if (!newUser) {
|
||||||
|
throw new Error("error inserting user");
|
||||||
|
}
|
||||||
|
return newUser;
|
||||||
|
} catch(e) {
|
||||||
|
console.log("ERROR on insertLingdocsUser", user);
|
||||||
|
console.log(e);
|
||||||
throw new Error("error inserting user");
|
throw new Error("error inserting user");
|
||||||
}
|
}
|
||||||
return newUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteLingdocsUser(uuid: T.UUID): Promise<void> {
|
export async function deleteLingdocsUser(uuid: T.UUID): Promise<void> {
|
||||||
|
@ -104,7 +110,7 @@ export async function updateLingdocsUser(uuid: T.UUID, toUpdate:
|
||||||
): Promise<T.LingdocsUser> {
|
): Promise<T.LingdocsUser> {
|
||||||
const user = await getLingdocsUser("userId", uuid);
|
const user = await getLingdocsUser("userId", uuid);
|
||||||
if (!user) throw new Error("unable to update - user not found " + uuid);
|
if (!user) throw new Error("unable to update - user not found " + uuid);
|
||||||
// console.log("inUpdateLingdocsUser", toUpdate);
|
console.log("inUpdateLingdocsUser", toUpdate);
|
||||||
if ("tests" in toUpdate) {
|
if ("tests" in toUpdate) {
|
||||||
return await insertLingdocsUser({
|
return await insertLingdocsUser({
|
||||||
...user,
|
...user,
|
||||||
|
|
Loading…
Reference in New Issue