diff --git a/.graphqlrc b/.graphqlrc index 0c330da9f..50a43c119 100644 --- a/.graphqlrc +++ b/.graphqlrc @@ -1,4 +1,4 @@ -schema: 'http://localhost:3000/graphql' +schema: 'http://127.0.0.1:3000/graphql' extensions: languageService: # Cause it's busted diff --git a/docker-compose-speckle.yml b/docker-compose-speckle.yml index 33519479d..b3e4136c7 100644 --- a/docker-compose-speckle.yml +++ b/docker-compose-speckle.yml @@ -29,7 +29,7 @@ services: start_period: 90s environment: # TODO: Change this to the URL of the speckle server, as accessed from the network - CANONICAL_URL: 'http://localhost' + CANONICAL_URL: 'http://127.0.0.1' # TODO: Change this to a unique secret for this server SESSION_SECRET: 'TODO:Replace' diff --git a/packages/fileimport-service/ifc/index.js b/packages/fileimport-service/ifc/index.js index cdeb45a26..caaae0a54 100644 --- a/packages/fileimport-service/ifc/index.js +++ b/packages/fileimport-service/ifc/index.js @@ -54,7 +54,7 @@ async function parseAndCreateCommit({ const userToken = process.env.USER_TOKEN - const serverBaseUrl = process.env.SPECKLE_SERVER_URL || 'http://localhost:3000' + const serverBaseUrl = process.env.SPECKLE_SERVER_URL || 'http://127.0.0.1:3000' logger.info(`Creating commit for object (${id}), with message "${message}"`) const response = await fetch(serverBaseUrl + '/graphql', { method: 'POST', diff --git a/packages/fileimport-service/knex.js b/packages/fileimport-service/knex.js index 3d2896156..37b663b9c 100644 --- a/packages/fileimport-service/knex.js +++ b/packages/fileimport-service/knex.js @@ -6,7 +6,7 @@ module.exports = require('knex')({ connection: { application_name: 'speckle_fileimport_service', connectionString: - process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@localhost/speckle' + process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@127.0.0.1/speckle' }, pool: { min: 0, max: 1 } // migrations are in managed in the server package diff --git a/packages/fileimport-service/obj/import_file.py b/packages/fileimport-service/obj/import_file.py index b5cb87b85..3a7cb3b04 100644 --- a/packages/fileimport-service/obj/import_file.py +++ b/packages/fileimport-service/obj/import_file.py @@ -125,7 +125,7 @@ def import_obj(): # Commit client = SpeckleClient( - host=os.getenv("SPECKLE_SERVER_URL", "localhost:3000"), use_ssl=False + host=os.getenv("SPECKLE_SERVER_URL", "127.0.0.1:3000"), use_ssl=False ) client.authenticate_with_token(os.environ["USER_TOKEN"]) diff --git a/packages/fileimport-service/package.json b/packages/fileimport-service/package.json index a7f90244b..f65f5bb34 100644 --- a/packages/fileimport-service/package.json +++ b/packages/fileimport-service/package.json @@ -15,7 +15,7 @@ "node": "^18.17.0" }, "scripts": { - "dev": "cross-env POSTGRES_URL=postgres://speckle:speckle@localhost/speckle NODE_ENV=development LOG_PRETTY=true SPECKLE_SERVER_URL=http://localhost:3000 nodemon --no-experimental-fetch ./src/daemon.js", + "dev": "cross-env POSTGRES_URL=postgres://speckle:speckle@127.0.0.1/speckle NODE_ENV=development LOG_PRETTY=true SPECKLE_SERVER_URL=http://127.0.0.1:3000 nodemon --no-experimental-fetch ./src/daemon.js", "parse:ifc": "node --no-experimental-fetch ./ifc/import_file.js ./ifc/ifcs/steelplates.ifc 33763848d6 2e4bfb467a main File upload: steelplates.ifc", "lint": "eslint . --ext .js,.ts" }, diff --git a/packages/fileimport-service/stl/import_file.py b/packages/fileimport-service/stl/import_file.py index 92e182108..a31830e22 100644 --- a/packages/fileimport-service/stl/import_file.py +++ b/packages/fileimport-service/stl/import_file.py @@ -35,7 +35,7 @@ def import_stl(): # Commit client = SpeckleClient( - host=os.getenv("SPECKLE_SERVER_URL", "localhost:3000"), use_ssl=False + host=os.getenv("SPECKLE_SERVER_URL", "127.0.0.1:3000"), use_ssl=False ) client.authenticate_with_token(os.environ["USER_TOKEN"]) diff --git a/packages/frontend-2/lib/common/generated/gql/graphql.ts b/packages/frontend-2/lib/common/generated/gql/graphql.ts index 02afe32ff..017492497 100644 --- a/packages/frontend-2/lib/common/generated/gql/graphql.ts +++ b/packages/frontend-2/lib/common/generated/gql/graphql.ts @@ -54,6 +54,37 @@ export type ActivityCollection = { totalCount: Scalars['Int']; }; +export type AdminQueries = { + __typename?: 'AdminQueries'; + projectList: ProjectCollection; + serverStatistics: ServerStatistics; + userList: AdminUserList; +}; + + +export type AdminQueriesProjectListArgs = { + cursor?: InputMaybe; + limit?: Scalars['Int']; + orderBy?: InputMaybe; + query?: InputMaybe; + visibility?: InputMaybe; +}; + + +export type AdminQueriesUserListArgs = { + cursor?: InputMaybe; + limit?: Scalars['Int']; + query?: InputMaybe; + role?: InputMaybe; +}; + +export type AdminUserList = { + __typename?: 'AdminUserList'; + cursor?: Maybe; + items: Array; + totalCount: Scalars['Int']; +}; + export type AdminUsersListCollection = { __typename?: 'AdminUsersListCollection'; items: Array; @@ -1581,11 +1612,16 @@ export type Query = { _?: Maybe; /** Gets the profile of the authenticated user or null if not authenticated */ activeUser?: Maybe; - /** All the streams of the server. Available to admins only. */ + admin: AdminQueries; + /** + * All the streams of the server. Available to admins only. + * @deprecated use admin.projectList instead + */ adminStreams?: Maybe; /** * Get all (or search for specific) users, registered or invited, from the server in a paginated view. * The query looks for matches in name, company and email. + * @deprecated use admin.UserList instead */ adminUsers?: Maybe; /** Gets a specific app from the server. */ @@ -1615,6 +1651,7 @@ export type Query = { */ projectInvite?: Maybe; serverInfo: ServerInfo; + /** @deprecated use admin.serverStatistics instead */ serverStats: ServerStats; /** * Returns a specific stream. Will throw an authorization error if active user isn't authorized @@ -1834,6 +1871,7 @@ export type ServerInfo = { canonicalUrl?: Maybe; company?: Maybe; description?: Maybe; + guestModeEnabled: Scalars['Boolean']; inviteOnly?: Maybe; name: Scalars['String']; roles: Array>; @@ -1846,6 +1884,7 @@ export type ServerInfoUpdateInput = { adminContact?: InputMaybe; company?: InputMaybe; description?: InputMaybe; + guestModeEnabled?: InputMaybe; inviteOnly?: InputMaybe; name: Scalars['String']; termsOfService?: InputMaybe; @@ -1866,9 +1905,17 @@ export type ServerInviteCreateInput = { export enum ServerRole { ServerAdmin = 'SERVER_ADMIN', ServerArchivedUser = 'SERVER_ARCHIVED_USER', + ServerGuest = 'SERVER_GUEST', ServerUser = 'SERVER_USER' } +export type ServerStatistics = { + __typename?: 'ServerStatistics'; + totalPendingInvites: Scalars['Int']; + totalProjectCount: Scalars['Int']; + totalUserCount: Scalars['Int']; +}; + export type ServerStats = { __typename?: 'ServerStats'; /** An array of objects currently structured as { created_month: Date, count: int }. */ diff --git a/packages/frontend/.vscode/launch.json b/packages/frontend/.vscode/launch.json index ed8b45d76..d0c177764 100644 --- a/packages/frontend/.vscode/launch.json +++ b/packages/frontend/.vscode/launch.json @@ -9,7 +9,7 @@ "request": "launch", "reAttach": true, "name": "Launch localhost", - "url": "http://localhost:3000", + "url": "http://127.0.0.1:3000", "webRoot": "${workspaceFolder}", "sourceMaps": true, "trace": true, @@ -21,10 +21,10 @@ ] }, { - "type": "pwa-chrome", + "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", - "url": "http://localhost:3000", + "url": "http://127.0.0.1:3000", "webRoot": "${workspaceFolder}", "sourceMaps": true, "trace": true, diff --git a/packages/frontend/apollo.config.js b/packages/frontend/apollo.config.js index 1a6ebf732..da47f5062 100644 --- a/packages/frontend/apollo.config.js +++ b/packages/frontend/apollo.config.js @@ -1,7 +1,7 @@ module.exports = { client: { service: 'speckle-server', - url: 'http://localhost:3000/graphql', + url: 'http://127.0.0.1:3000/graphql', includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}'] } } diff --git a/packages/preview-service/Makefile b/packages/preview-service/Makefile index 821eed5b2..686650ad8 100644 --- a/packages/preview-service/Makefile +++ b/packages/preview-service/Makefile @@ -5,15 +5,15 @@ build: run: docker run -it --rm --net=host \ - -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \ + -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" \ preview-service run-release: docker run -it --rm --net=host \ - -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \ + -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" \ speckle/speckle-preview-service:v2.3.3 small: docker build -t small-preview-service ../.. -f Dockerfile.small - docker run -it --rm --net=host -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" small-preview-service bash + docker run -it --rm --net=host -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" small-preview-service bash diff --git a/packages/preview-service/knex.js b/packages/preview-service/knex.js index 75f74a8a5..ac84a9712 100644 --- a/packages/preview-service/knex.js +++ b/packages/preview-service/knex.js @@ -6,7 +6,7 @@ module.exports = require('knex')({ connection: { application_name: 'speckle_preview_service', connectionString: - process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@localhost/speckle' + process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@127.0.0.1/speckle' }, pool: { min: 0, max: 2 } // migrations are in managed in the server package diff --git a/packages/preview-service/readme.md b/packages/preview-service/readme.md index 167a22781..831d7c0af 100644 --- a/packages/preview-service/readme.md +++ b/packages/preview-service/readme.md @@ -24,7 +24,7 @@ After the viewer web page is up to date, run the preview service with: yarn dev ``` -This will use the default dev DB connection of `postgres://speckle:speckle@localhost/speckle`. You can pass the environment variable `PG_CONNECTION_STRING` to change this to a different DB. +This will use the default dev DB connection of `postgres://speckle:speckle@127.0.0.1/speckle`. You can pass the environment variable `PG_CONNECTION_STRING` to change this to a different DB. ## Deployment notes diff --git a/packages/server/.env-example b/packages/server/.env-example index 8130a3a26..16525aad1 100644 --- a/packages/server/.env-example +++ b/packages/server/.env-example @@ -35,7 +35,7 @@ ONBOARDING_STREAM_CACHE_BUST_NUMBER=1 # If you specify a user and password, do not specify the protocol in the # POSTGRES_URL variable. # These defaults are set for the local development environment -POSTGRES_URL="localhost" +POSTGRES_URL="127.0.0.1" # this overrides the default root user in the postgres instance POSTGRES_USER="speckle" # this sets the root user password in the postgres instance @@ -123,7 +123,7 @@ STRATEGY_LOCAL=true # If your frontend is served in dev from somewhere else, # this is going to help out :) ############################################################ -# FRONTEND_HOST=localhost +# FRONTEND_HOST=127.0.0.1 # FRONTEND_PORT=8081 SPECKLE_AUTOMATE_URL="http://127.0.0.1:3030" diff --git a/packages/server/app.ts b/packages/server/app.ts index f0f82d876..cb30589db 100644 --- a/packages/server/app.ts +++ b/packages/server/app.ts @@ -355,7 +355,7 @@ export async function shutdown(): Promise { const shouldUseFrontendProxy = () => process.env.NODE_ENV === 'development' async function createFrontendProxy() { - const frontendHost = process.env.FRONTEND_HOST || 'localhost' + const frontendHost = process.env.FRONTEND_HOST || '127.0.0.1' const frontendPort = process.env.FRONTEND_PORT || 8080 const { createProxyMiddleware } = await import('http-proxy-middleware') @@ -388,7 +388,7 @@ export async function startHttp( app.use(await createFrontendProxy()) startupLogger.info('✨ Proxying frontend-1 (dev mode):') - startupLogger.info(`👉 main application: http://localhost:${port}/`) + startupLogger.info(`👉 main application: http://127.0.0.1:${port}/`) } // Production mode diff --git a/packages/server/knexfile.js b/packages/server/knexfile.js index 0306ab2c6..bcef7f96a 100644 --- a/packages/server/knexfile.js +++ b/packages/server/knexfile.js @@ -84,14 +84,14 @@ const config = { test: { ...commonConfig, connection: { - connectionString: connectionUri || 'postgres://localhost/speckle2_test', + connectionString: connectionUri || 'postgres://127.0.0.1/speckle2_test', application_name: 'speckle_server' } }, development: { ...commonConfig, connection: { - connectionString: connectionUri || 'postgres://localhost/speckle2_dev', + connectionString: connectionUri || 'postgres://127.0.0.1/speckle2_dev', application_name: 'speckle_server' } }, diff --git a/packages/server/modules/auth/tests/apps.spec.js b/packages/server/modules/auth/tests/apps.spec.js index 3a63e5306..798381262 100644 --- a/packages/server/modules/auth/tests/apps.spec.js +++ b/packages/server/modules/auth/tests/apps.spec.js @@ -67,7 +67,7 @@ describe('Services @apps-services', () => { name: 'test application', public: true, scopes: [Scopes.Streams.Read], - redirectUrl: 'http://localhost:1335' + redirectUrl: 'http://127.0.0.1:1335' }) expect(res).to.have.property('id') @@ -88,7 +88,7 @@ describe('Services @apps-services', () => { }) it('Should fail to register an app with no scopes', async () => { - await createApp({ name: 'test application2', redirectUrl: 'http://localhost:1335' }) + await createApp({ name: 'test application2', redirectUrl: 'http://127.0.0.1:1335' }) .then(() => { throw new Error('this should have been rejected') }) diff --git a/packages/server/modules/cli/commands/bull/monitor.ts b/packages/server/modules/cli/commands/bull/monitor.ts index 88038692f..fc684ba12 100644 --- a/packages/server/modules/cli/commands/bull/monitor.ts +++ b/packages/server/modules/cli/commands/bull/monitor.ts @@ -47,7 +47,7 @@ const command: CommandModule = { app.listen(PORT, () => { cliLogger.info(`Running on ${PORT}...`) cliLogger.info( - `For the UI, open http://localhost:${PORT}/, and make sure Redis is running` + `For the UI, open http://127.0.0.1:${PORT}/, and make sure Redis is running` ) }) diff --git a/packages/server/modules/core/services/generic.js b/packages/server/modules/core/services/generic.js index ef749fdce..e472151ef 100644 --- a/packages/server/modules/core/services/generic.js +++ b/packages/server/modules/core/services/generic.js @@ -12,7 +12,7 @@ module.exports = { async getServerInfo() { const serverInfo = await Info().select('*').first() serverInfo.version = process.env.SPECKLE_SERVER_VERSION || 'dev' - serverInfo.canonicalUrl = process.env.CANONICAL_URL || 'localhost' + serverInfo.canonicalUrl = process.env.CANONICAL_URL || '127.0.0.1' return serverInfo }, diff --git a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts index 98e3ebbf6..a711b8319 100644 --- a/packages/server/modules/cross-server-sync/graph/generated/graphql.ts +++ b/packages/server/modules/cross-server-sync/graph/generated/graphql.ts @@ -1874,6 +1874,7 @@ export type ServerInfo = { canonicalUrl?: Maybe; company?: Maybe; description?: Maybe; + guestModeEnabled: Scalars['Boolean']; inviteOnly?: Maybe; name: Scalars['String']; roles: Array>; @@ -1886,6 +1887,7 @@ export type ServerInfoUpdateInput = { adminContact?: InputMaybe; company?: InputMaybe; description?: InputMaybe; + guestModeEnabled?: InputMaybe; inviteOnly?: InputMaybe; name: Scalars['String']; termsOfService?: InputMaybe; @@ -1906,6 +1908,7 @@ export type ServerInviteCreateInput = { export enum ServerRole { ServerAdmin = 'SERVER_ADMIN', ServerArchivedUser = 'SERVER_ARCHIVED_USER', + ServerGuest = 'SERVER_GUEST', ServerUser = 'SERVER_USER' } diff --git a/packages/server/modules/emails/utils/transporter.ts b/packages/server/modules/emails/utils/transporter.ts index 905373662..27f220217 100644 --- a/packages/server/modules/emails/utils/transporter.ts +++ b/packages/server/modules/emails/utils/transporter.ts @@ -8,7 +8,7 @@ const createJsonEchoTransporter = () => createTransport({ jsonTransport: true }) const initSmtpTransporter = async () => { try { const smtpTransporter = createTransport({ - host: process.env.EMAIL_HOST || 'localhost', + host: process.env.EMAIL_HOST || '127.0.0.1', port: parseInt(process.env.EMAIL_PORT || '587'), secure: process.env.EMAIL_SECURE === 'true', auth: { diff --git a/packages/server/readme.md b/packages/server/readme.md index 71713cec7..78afe2fcd 100644 --- a/packages/server/readme.md +++ b/packages/server/readme.md @@ -32,7 +32,7 @@ After you have PostgreSQL and Redis running, in the `packages/server` folder: - If you have a custom setup, open and edit the `.env` & `.env.test` files, filling in the required variables, - run `yarn install`, - finally `yarn dev`, -- check `localhost:3000/graphql` out! +- check `127.0.0.1:3000/graphql` out! ## Developing @@ -72,18 +72,18 @@ Use `yarn cli bull monitor` to serve a Web UI for our Bull queues (e.g. Notifica ### Frontend -- In **development** mode, the Speckle Server will proxy the frontend from `localhost:3000` to `localhost:8080`. +- In **development** mode, the Speckle Server will proxy the frontend from `127.0.0.1:3000` to `127.0.0.1:8080`. If you don't see anything, ensure you've run `yarn dev` in the frontend package. - In **production** mode, the frontend is served by an `nginx` container that proxy server requests to the server (depending on the requested path). For more information about making a production deployment, check out [our detailed guide](https://speckle.guide/dev/server-setup.html) ### GraphIQL -A GraphIQL app is available for authenticated api exploration at `localhost:3000/explorer`. Note that for the authentication flow to work, you need to have the frontend running first. +A GraphIQL app is available for authenticated api exploration at `127.0.0.1:3000/explorer`. Note that for the authentication flow to work, you need to have the frontend running first. ### GraphQL Playground -For non-authenticated api exploration, you can use the Graphql Playground which is available by default at `localhost:3000/graphql`. +For non-authenticated api exploration, you can use the Graphql Playground which is available by default at `127.0.0.1:3000/graphql`. ## Testing