Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
fixed issue with server and app
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLoir committed Mar 5, 2024
1 parent 5f9f60e commit 3d86b0b
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 19 deletions.
9 changes: 8 additions & 1 deletion apps/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
"strict": true,
"baseUrl": ".",
"paths": {
"@/trpc": ["../../packages/api/src/trpc.ts"],
"@/languages/*": ["../../packages/api/src/languages/*"],
"@/schemas/*": ["../../packages/api/src/schemas/*"],
"@/utils": ["../../packages/api/src/utils.ts"]
}
},
"exclude": ["node_modules", "dist", "babel.config.js", "tailwind.config.js", "metro.config.js"]
}
6 changes: 6 additions & 0 deletions apps/server/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ const config: Config.InitialOptions = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
moduleNameMapper: {
'^@/trpc$': '<rootDir>/../../../packages/api/src/trpc.ts',
'^@/utils$': '<rootDir>/../../../packages/api/src/utils.ts',
'^@/schemas$': '<rootDir>/../../../packages/api/src/schemas',
'^@/languages$': '<rootDir>/../../../packages/api/src/languages',
},
};
export default config;
2 changes: 2 additions & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@repo/eslint-config": "^0.0.0",
"@repo/typescript-config": "^0.0.0",
"@types/express": "^4.17.21",
"@types/module-alias": "^2.0.4",
"@types/node": "^20.11.24",
"@types/ws": "^8.5.10",
"eslint": "^8.57.0",
Expand All @@ -28,6 +29,7 @@
"@types/jest": "^29.5.12",
"dotenv": "^16.4.5",
"jest": "^29.7.0",
"module-alias": "^2.2.3",
"spawn-command-with-kill": "^1.0.2",
"ts-jest": "^29.1.2",
"ws": "^8.16.0"
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './paths';
import dotenv from 'dotenv';
import { createHTTPServer } from '@trpc/server/adapters/standalone';
import { AppRouter, appRouter, createContext } from '@repo/api';
Expand Down
9 changes: 9 additions & 0 deletions apps/server/src/paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'module-alias/register';
import { addAliases } from 'module-alias';

addAliases({
'@/trpc': __dirname + '/../../../packages/api/src/trpc.ts',
'@/utils': __dirname + '/../../../packages/api/src/utils.ts',
'@/schemas': __dirname + '/../../../packages/api/src/schemas',
'@/languages': __dirname + '/../../../packages/api/src/languages',
});
11 changes: 6 additions & 5 deletions apps/server/tests/trpc.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../src/paths';
/* eslint-disable no-undef */
import { createTRPCClient, httpBatchLink } from '@trpc/client';
import { AppRouter } from '@repo/api';
Expand Down Expand Up @@ -99,7 +100,7 @@ describe('lsp capabilities', () => {
await init(trpc, fileDir);

// Open the file index.ts in the LSP session
await trpc.lsp.didOpen.query({
await trpc.lsp.textDocument.didOpen.query({
language: 'typescript',
options: {
textDocument: {
Expand All @@ -113,7 +114,7 @@ describe('lsp capabilities', () => {
});

it('should give info about hover', async () => {
const result = await trpc.lsp.hover.query({
const result = await trpc.lsp.textDocument.hover.query({
language: 'typescript',
options: {
textDocument: {
Expand All @@ -125,12 +126,12 @@ describe('lsp capabilities', () => {
},
},
});

expect(result.contents.value).toContain('console');
if (typeof result.contents === 'object' && 'value' in result.contents)
expect(result.contents.value).toContain('console');
});

it('should give info about semantic tokens', async () => {
const result = await trpc.lsp.semanticTokens.query({
const result = await trpc.lsp.textDocument.semanticTokens.query({
language: 'typescript',
options: {
textDocument: {
Expand Down
9 changes: 8 additions & 1 deletion apps/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/trpc": ["../../packages/api/src/trpc.ts"],
"@/languages/*": ["../../packages/api/src/languages/*"],
"@/schemas/*": ["../../packages/api/src/schemas/*"],
"@/utils": ["../../packages/api/src/utils.ts"]
}
},
"include": ["src/**/*.ts", "tests/**/*.ts"],
"include": ["src/**/*.ts", "tests/**/*.ts", ],
"exclude": ["node_modules"]
}
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions packages/api/src/routes/lsp/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { router } from '@/trpc';
import { hoverRoute } from './hover';
import { initializeRoute } from './initialize';
import { semanticTokensRoute } from './semanticTokens';
import { didOpenRoute } from './didOpenRoute';
import { initializeRoute } from './initializeRoute';
import { windowRouter } from './window/windowRouter';
import { textDocumentRouter } from './textDocument/textDocumentRouter';

export const lspRouter = router({
hover: hoverRoute,
initialize: initializeRoute,
semanticTokens: semanticTokensRoute,
didOpen: didOpenRoute,
window: windowRouter,
textDocument: textDocumentRouter,
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { publicProcedure } from '@/trpc';
import { getClient, lspRouterInputSchema } from './clients';
import { getClient, lspRouterInputSchema } from '../clients';
import { didOpenTextDocumentParamsSchema } from '@/schemas/zodSchemas';

export const openInputSchema = lspRouterInputSchema.extend({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { publicProcedure } from '@/trpc';
import { hoverParamsSchema, hoverSchema } from '@/schemas/zodSchemas';
import { getClient, lspRouterInputSchema } from './clients';
import { getClient, lspRouterInputSchema } from '../clients';
export const hoverInputSchema = lspRouterInputSchema.extend({
options: hoverParamsSchema,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { publicProcedure } from '@/trpc';
import { getClient, lspRouterInputSchema } from './clients';
import { getClient, lspRouterInputSchema } from '../clients';
import { z } from 'zod';
export const semanticTokensInputSchema = lspRouterInputSchema.extend({
options: z.object({
Expand Down
10 changes: 10 additions & 0 deletions packages/api/src/routes/lsp/textDocument/textDocumentRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { router } from '@/trpc';
import { didOpenRoute } from './didOpenRoute';
import { hoverRoute } from './hoverRoute';
import { semanticTokensRoute } from './semanticTokensRoute';

export const textDocumentRouter = router({
didOpen: didOpenRoute,
hover: hoverRoute,
semanticTokens: semanticTokensRoute,
});
2 changes: 1 addition & 1 deletion packages/api/src/routes/lsp/window/windowRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { router } from '@/trpc';
import { showMessageRoute } from './showMessage';
import { showMessageRoute } from './showMessageRoute';

export const windowRouter = router({
showMessage: showMessageRoute,
Expand Down
1 change: 0 additions & 1 deletion packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@repo/typescript-config/react-library.json",
"compilerOptions": {
"outDir": "dist",
"baseUrl": "./",
"paths": {
"@/trpc": ["./src/trpc.ts"],
"@/languages/*": ["./src/languages/*"],
Expand Down

0 comments on commit 3d86b0b

Please sign in to comment.