You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							31 lines
						
					
					
						
							636 B
						
					
					
				
			
		
		
	
	
							31 lines
						
					
					
						
							636 B
						
					
					
				'use strict'
 | 
						|
 | 
						|
const fastify = require('fastify')({ logger: true })
 | 
						|
 | 
						|
const opts = {
 | 
						|
  addToBody: true,
 | 
						|
  sharedSchemaId: '#mySharedSchema'
 | 
						|
}
 | 
						|
fastify.register(require('..'), opts)
 | 
						|
 | 
						|
fastify.post('/upload/files', {
 | 
						|
  schema: {
 | 
						|
    body: {
 | 
						|
      type: 'object',
 | 
						|
      required: ['myStringField'],
 | 
						|
      properties: {
 | 
						|
        myStringField: { type: 'string' },
 | 
						|
        myFilenameField: { $ref: '#mySharedSchema' }
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
}, function (req, reply) {
 | 
						|
  console.log({ body: req.body })
 | 
						|
  reply.send('done')
 | 
						|
})
 | 
						|
 | 
						|
fastify.listen(3000, err => {
 | 
						|
  if (err) throw err
 | 
						|
  console.log(`server listening on ${fastify.server.address().port}`)
 | 
						|
})
 |