- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.4k
 
feat: Add TypeScript support #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            mtrezza
  merged 23 commits into
  parse-community:master
from
abubkr-hago:feat/typescript-support
  
      
      
   
  Apr 28, 2025 
      
    
  
     Merged
                    Changes from 14 commits
      Commits
    
    
            Show all changes
          
          
            23 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      6db0e54
              
                feat: add typescript support
              
              
                abubkr-hago fca9f06
              
                feat: apply tsconfig from parse-server and fix errors
              
              
                abubkr-hago 03d49ed
              
                feat: update Dockerfile to build and package the compiled code
              
              
                abubkr-hago 5569c03
              
                feat: configure eslint with tseslint
              
              
                abubkr-hago 99c9bcf
              
                fix: docker ignore file
              
              
                abubkr-hago 0eec7ee
              
                fix: build failure due to es module config
              
              
                abubkr-hago 640f833
              
                fix: invalid CMD command for Dockerfile
              
              
                abubkr-hago 7b03f63
              
                refactor: move express routes outside server start promise
              
              
                abubkr-hago edf059c
              
                fix: eslint config to apply on spec folder without emitting files dur…
              
              
                abubkr-hago 7f5b807
              
                fix: apply eslint to the whole project
              
              
                abubkr-hago cd8dca4
              
                fix: run jasmine tests using tsx
              
              
                abubkr-hago 5217420
              
                fix: inconsistent node version between stages
              
              
                abubkr-hago 4c97627
              
                fix: remove ENV variables and better structure files inside image
              
              
                abubkr-hago fd27b5b
              
                docs: add docker deployment documentation
              
              
                abubkr-hago 9dc780b
              
                fix: remove range ops from newly added packages
              
              
                abubkr-hago cfa5f83
              
                feat: increase module and target to support more features
              
              
                abubkr-hago b7d3c78
              
                Merge branch 'master' into feat/typescript-support
              
              
                abubkr-hago 5c95cde
              
                fix: remove range op for typescript-eslint package
              
              
                abubkr-hago 667f8db
              
                fix: specify rootDir for clearer project boundaries
              
              
                abubkr-hago 22bfac1
              
                fix: module detection
              
              
                abubkr-hago 9ad95ae
              
                fix: ensure dynamic imports complete with await
              
              
                abubkr-hago f636536
              
                fix: adding syntax highlighting to code blocks
              
              
                abubkr-hago bf5b023
              
                fix: use Node.js 20 LTS for Production Builds
              
              
                abubkr-hago File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| 
     | 
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| 
     | 
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
| 
     | 
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| .nyc_output | ||
| 
     | 
||
| # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
| 
     | 
||
| # node-waf configuration | ||
| .lock-wscript | ||
| 
     | 
||
| # Compiled binary addons (http://nodejs.org/api/addons.html) | ||
| build/Release | ||
| 
     | 
||
| # Dependency directory | ||
| # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
| node_modules | ||
| 
     | 
||
| # Emacs | ||
| *~ | ||
| .eslintcache | ||
| 
     | 
||
| # build folder | ||
| dist | ||
| 
     | 
||
| # Docker files | ||
| Docker* | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| APP_ID=myAppId | ||
| MASTER_KEY=myMasterKey | ||
| MONGODB_URI=mongodb://localhost:27017/parse | ||
| PORT=1337 | ||
| SERVER_URL=http://localhost:1337 | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -30,3 +30,10 @@ node_modules | |
| # Emacs | ||
| *~ | ||
| .eslintcache | ||
| 
     | 
||
| # build folder | ||
| dist | ||
| 
     | 
||
| # env files | ||
| .env* | ||
| !.env.example | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,26 +1,28 @@ | ||
| FROM node:latest | ||
| # Builder stage | ||
| FROM node:22.12.0-alpine AS builder | ||
                
      
                  abubkr-hago marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| RUN mkdir parse | ||
| WORKDIR /usr/src/parse | ||
| 
     | 
||
| COPY package*.json . | ||
| 
     | 
||
| ADD . /parse | ||
| WORKDIR /parse | ||
| RUN npm install | ||
| 
     | 
||
| ENV APP_ID setYourAppId | ||
| ENV MASTER_KEY setYourMasterKey | ||
| ENV DATABASE_URI setMongoDBURI | ||
| COPY . . | ||
| 
     | 
||
| # Optional (default : 'parse/cloud/main.js') | ||
| # ENV CLOUD_CODE_MAIN cloudCodePath | ||
| RUN npm run build | ||
| 
     | 
||
| # Optional (default : '/parse') | ||
| # ENV PARSE_MOUNT mountPath | ||
| # latest supported node version when this Dockerfile was written | ||
| FROM node:22.12.0-alpine | ||
| 
     | 
||
| EXPOSE 1337 | ||
| WORKDIR /usr/src/parse | ||
| 
     | 
||
| # Uncomment if you want to access cloud code outside of your container | ||
| # A main.js file must be present, if not Parse will not start | ||
| # Copy only the required files from the builder stage | ||
| COPY --from=builder /usr/src/parse/node_modules ./node_modules | ||
| COPY --from=builder /usr/src/parse/dist ./ | ||
| COPY --from=builder /usr/src/parse/public ./public | ||
| 
     | 
||
| # VOLUME /parse/cloud | ||
| VOLUME ["/usr/src/parse/cloud", "/usr/src/parse/logs"] | ||
| 
     | 
||
| EXPOSE 1337 | ||
| 
     | 
||
| CMD [ "npm", "start" ] | ||
| CMD ["node", "index.js"] | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| Parse.Cloud.define('hello', req => { | ||
| // @ts-expect-error req.log exists, but it was not added to types/parse | ||
| req.log.info(req); | ||
| return 'Hi'; | ||
| }); | ||
| 
     | 
||
| Parse.Cloud.define('helloAsyncFunction', async req => { | ||
| await new Promise(resolve => setTimeout(resolve, 1000)); | ||
| // @ts-expect-error req.log exists, but it was not added to types/parse | ||
| req.log.info(req); | ||
| return 'Hi async'; | ||
| }); | ||
| 
     | 
||
| Parse.Cloud.beforeSave('TestObject', () => { | ||
| throw new Parse.Error(9001, 'Saving test objects is not available.'); | ||
| throw new Parse.Error(Parse.Error.OTHER_CAUSE, 'Saving test objects is not available.'); | ||
| }); | ||
| 
     | 
||
| export {}; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // It is best practise to organize your cloud functions group into their own file. You can then import them in your main.js. | ||
| await Promise.all([ | ||
| import('./functions.js') | ||
| ]); | ||
| Promise.all([import('./functions.js')]); | ||
                
      
                  abubkr-hago marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| export {}; | ||
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export const schemaDefinitions = [ | ||
| { | ||
| className: 'TestObject', | ||
| fields: { | ||
| beforeSave: { type: 'Boolean', defaultValue: false }, | ||
| additionalData: { type: 'String' }, | ||
| }, | ||
| classLevelPermissions: { | ||
| find: { '*': true }, | ||
| count: { '*': true }, | ||
| get: { '*': true }, | ||
| update: { '*': true }, | ||
| create: { '*': true }, | ||
| delete: { '*': true }, | ||
| }, | ||
| }, | ||
| ]; | ||
                
      
                  mtrezza marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import js from '@eslint/js'; | ||
| import tseslint from 'typescript-eslint'; | ||
| import globals from 'globals'; | ||
| import path from 'node:path'; | ||
| 
     | 
||
| const __dirname = path.resolve(); | ||
                
      
                  mtrezza marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| export default tseslint.config( | ||
| js.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| { | ||
| files: ['**/*.ts'], | ||
| languageOptions: { | ||
| ecmaVersion: 2022, | ||
| sourceType: 'module', | ||
| parser: tseslint.parser, | ||
| parserOptions: { | ||
| project: ['./tsconfig.json', './spec/tsconfig.json'], | ||
| tsconfigRootDir: __dirname, | ||
| }, | ||
| globals: { | ||
| ...globals.node, | ||
| Parse: 'readonly', | ||
| }, | ||
| }, | ||
| rules: { | ||
| '@typescript-eslint/explicit-function-return-type': 'off', | ||
| '@typescript-eslint/no-explicit-any': 'warn', | ||
| '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
| indent: ['error', 2, { SwitchCase: 1 }], | ||
| 'linebreak-style': ['error', 'unix'], | ||
| 'no-trailing-spaces': 'error', | ||
| 'eol-last': 'error', | ||
| 'space-in-parens': ['error', 'never'], | ||
| 'no-multiple-empty-lines': 'warn', | ||
| 'prefer-const': 'error', | ||
| 'space-infix-ops': 'error', | ||
| 'no-useless-escape': 'off', | ||
| 'require-atomic-updates': 'off', | ||
| 'no-var': 'warn', | ||
| 'no-await-in-loop': 'warn', | ||
| }, | ||
| }, | ||
| { | ||
| ignores: ['dist/**/*', 'logs/**/*', 'public/**/*', 'release.config.js'], | ||
| } | ||
| ); | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "ignore": [ | ||
| "dist" | ||
| ], | ||
| "ext": "json,ts,mjs,cjs,js", | ||
| "execMap": { | ||
| "ts": "tsx" | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.