This commit is contained in:
lnn0q 2025-07-08 16:36:00 +03:00
parent c8f68b7486
commit e5126a4aca
6 changed files with 56 additions and 288 deletions

View file

@ -1,9 +1,9 @@
import { call } from '@app/common';
import { ensureIdentity } from '@app/server/helpers';
import { IdentityContext } from '@app/server/identity';
import { prisma, uuid } from '@app/server/prisma/client';
import { prisma } from '@app/server/prisma/client';
import { MutationUserUpdateArgs, User } from '@generated/types';
import { toUserSchema } from './mappers/userMapper';
import { call } from '@app/common';
export async function UserUpdateResolver(
_: any,
@ -12,7 +12,7 @@ export async function UserUpdateResolver(
): Promise<User> {
ensureIdentity(identity);
if (input.id != identity.id) throw new Error('Operation is not permitted.'); //todo: add admin access
if (input.id !== identity.id) throw new Error('Operation is not permitted.');
if (input.description != null && input.description.length > 700)
throw new Error('Description is too long.');

View file

@ -7,7 +7,7 @@ import 'dotenv/config';
import express from 'express';
import fs from 'fs';
import { GraphQLJSON } from 'graphql-scalars';
import https from 'https';
import http from 'http';
import path from 'path';
import ViteExpress from 'vite-express';
import { toAppConfig } from './config';
@ -18,11 +18,16 @@ import { getIdentityContext, IdentityContext } from './identity';
export const config = toAppConfig();
const __dirname = import.meta.dirname;
const key = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.key'));
const cert = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.crt'));
// todo - make built-in ssl conditional
// const key = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.key'));
// const cert = fs.readFileSync(path.join(__dirname + '../../../certs/selfsigned.crt'));
const app = express();
const server = https.createServer({ key, cert }, app);
// todo - make built-in ssl conditional
// const server = https.createServer({ key, cert }, app);
const server = http.createServer(app);
const typeDefs = fs.readFileSync(path.join(__dirname, 'graphql', 'schema.graphql'), 'utf8');